Inherits from NSObject
Conforms to ENOAuthViewControllerDelegate
SKStoreProductViewControllerDelegate
Declared in EvernoteSession.h
EvernoteSession.m

Overview

The EvernoteSession class provides a centralized place for authentication and gives access to the EvernoteNoteStore and EvernoteUserStore objects. Every application must have exactly one instance of EvernoteSession. When an application is ready, the application:didFinishLaunchingWithOptions: function is called, where you should call the class method setSharedSessionHost:consumerKey:consumerSecret:supportedService: Thereafter you can access this object by invoking the sharedSession class method.

Tasks

Other Methods

  •   delegate

    The delegate of the Evernote session

    property

Session data

  •   state

    The detailed state of the session

    property
  •   isAuthenticated

    Determines whether this session is authenticated or not.

    property
  •   authenticationToken

    Evernote auth token, to be passed to any NoteStore methods. Will only be non-nil once we’ve authenticated.

    property
  •   businessAuthenticationToken

    Evernote auth token for Business, to be passed to any NoteStore methods. Will only be non-nil once we’ve authenticated.

    property
  •   userStoreUrl

    URL for the Evernote UserStore.

    property
  •   noteStoreUrl

    URL for the Evernote NoteStore for the authenticated user. Will only be non-nil once we’ve authenticated.

    property
  •   webApiUrlPrefix

    URL prefix for the web API. Will only be non-nil once we’ve authenticated.

    property
  •   queue

    Shared dispatch queue for API operations.

    property
  •   profiles

    All the bootstrap profiles for the user.

    property
  •   businessUser

    The business user object.

    property

Session handling

Accessing user and notes data

Properties

authenticationToken

Evernote auth token, to be passed to any NoteStore methods. Will only be non-nil once we’ve authenticated.

@property (weak, nonatomic, readonly) NSString *authenticationToken

Discussion

Evernote auth token, to be passed to any NoteStore methods. Will only be non-nil once we’ve authenticated.

Declared In

EvernoteSession.h

businessAuthenticationToken

Evernote auth token for Business, to be passed to any NoteStore methods. Will only be non-nil once we’ve authenticated.

@property (weak, nonatomic, readonly) NSString *businessAuthenticationToken

Discussion

Evernote auth token for Business, to be passed to any NoteStore methods. Will only be non-nil once we’ve authenticated.

Declared In

EvernoteSession.h

businessUser

The business user object.

@property (nonatomic, strong) EDAMUser *businessUser

Discussion

The business user object.

Declared In

EvernoteSession.h

delegate

The delegate of the Evernote session

@property (nonatomic, assign) id<ENSessionDelegate> delegate

Discussion

The delegate of the Evernote session

Declared In

EvernoteSession.h

isAuthenticated

Determines whether this session is authenticated or not.

@property (nonatomic, readonly) BOOL isAuthenticated

Discussion

Determines whether this session is authenticated or not.

Declared In

EvernoteSession.h

noteStoreUrl

URL for the Evernote NoteStore for the authenticated user. Will only be non-nil once we’ve authenticated.

@property (weak, nonatomic, readonly) NSString *noteStoreUrl

Discussion

URL for the Evernote NoteStore for the authenticated user. Will only be non-nil once we’ve authenticated.

Declared In

EvernoteSession.h

profiles

All the bootstrap profiles for the user.

@property (nonatomic, strong) NSArray *profiles

Discussion

All the bootstrap profiles for the user.

Declared In

EvernoteSession.h

queue

Shared dispatch queue for API operations.

@property (nonatomic, readonly) dispatch_queue_t queue

Discussion

Shared dispatch queue for API operations.

Declared In

EvernoteSession.h

state

The detailed state of the session

@property (readonly) ENSessionState state

Discussion

The detailed state of the session

Declared In

EvernoteSession.h

userStoreUrl

URL for the Evernote UserStore.

@property (weak, nonatomic, readonly) NSString *userStoreUrl

Discussion

URL for the Evernote UserStore.

Declared In

EvernoteSession.h

webApiUrlPrefix

URL prefix for the web API. Will only be non-nil once we’ve authenticated.

@property (weak, nonatomic, readonly) NSString *webApiUrlPrefix

Discussion

URL prefix for the web API. Will only be non-nil once we’ve authenticated.

Declared In

EvernoteSession.h

Class Methods

setSharedSessionHost:consumerKey:consumerSecret:

Set up the shared session.

+ (void)setSharedSessionHost:(NSString *)host consumerKey:(NSString *)consumerKey consumerSecret:(NSString *)consumerSecret

Parameters

host

The server URL. “sandbox.yinxiang.com” should be used for testing .“www.evernote.com” for production apps.

consumerKey

The consumer key. Get your consumer key here.

consumerSecret

The consumer secret.

Discussion

Set up the shared session.

This should be called as soon as the application is ready to run.

Declared In

EvernoteSession.h

sharedSession

  • Get the singleton shared session.
+ (EvernoteSession *)sharedSession

Return Value

Returns the singleton session object.

Discussion

  • Get the singleton shared session.

Declared In

EvernoteSession.h

Instance Methods

authenticateWithViewController:completionHandler:

Authenticate, calling the given handler upon completion.

- (void)authenticateWithViewController:(UIViewController *)viewController completionHandler:(EvernoteAuthCompletionHandler)completionHandler

Parameters

viewController

The view controller that should be used to present the authentication view

completionHandler

This block will be called once the authentication process is completed with sucess or failure.

Discussion

Authenticate, calling the given handler upon completion.

This should be called to kick off the authentication process with Evernote.

Declared In

EvernoteSession.h

businessNoteStore

Create a new NoteStore client for EDAM calls.

- (EDAMNoteStoreClient *)businessNoteStore

Return Value

Returns the note store client.

Discussion

Create a new NoteStore client for EDAM calls.

This lets you make API calls for all the data in the user’s business account. This also handles authentication to business, as long as the Evernote session is authenticated. This function may throw an NSException. The returned object is NOT thread safe.

Declared In

EvernoteSession.h

canHandleOpenURL:

Handle open url from the Evernote app.

- (BOOL)canHandleOpenURL:(NSURL *)url

Parameters

url

The URL passed from the AppDelegate

Discussion

Handle open url from the Evernote app.

This will used during authentication and should be called from the AppDelegate class.

Declared In

EvernoteSession.h

handleDidBecomeActive

Application became active as a result of app switching.

- (void)handleDidBecomeActive

Discussion

Application became active as a result of app switching.

This will be used to handle unexpected events due to app switching.

Declared In

EvernoteSession.h

installEvernoteAppUsingViewController:

Install the evernote for iOS app.

- (void)installEvernoteAppUsingViewController:(UIViewController *)viewController

Parameters

viewController

The view controller that should be used as a base controller to present this view controller.

Discussion

Install the evernote for iOS app.

This can be used to present the user with a dialog to install the Evernote for iOS app

Declared In

EvernoteSession.h

isEvernoteInstalled

Check if the Evernote app is installed.

- (BOOL)isEvernoteInstalled

Discussion

Check if the Evernote app is installed.

Checks if the Evernote for IOS app is installed on the user’s device

Declared In

EvernoteSession.h

logout

Logout and clear authentication.

- (void)logout

Discussion

Logout and clear authentication.

This will clear all the cookies as well.

Declared In

EvernoteSession.h

noteStore

Create a new NoteStore client for EDAM calls.

- (EDAMNoteStoreClient *)noteStore

Return Value

Returns the note store client.

Discussion

Create a new NoteStore client for EDAM calls.

This lets you make API calls for all the data. This function may throw an NSException. The returned object is NOT thread safe.

Declared In

EvernoteSession.h

noteStoreWithNoteStoreURL:

Create a new NoteStore client for EDAM calls.

- (EDAMNoteStoreClient *)noteStoreWithNoteStoreURL:(NSString *)noteStoreURL

Parameters

noteStoreURL

The URL of the note store.

Return Value

Returns the note store client.

Discussion

Create a new NoteStore client for EDAM calls.

This lets you make API calls for all the data. This function may throw an NSException. The returned object is NOT thread safe.

Declared In

EvernoteSession.h

updateCurrentBootstrapProfileWithName:

Change the bootstrap profile.

- (void)updateCurrentBootstrapProfileWithName:(NSString *)aProfileName

Parameters

aProfileName

The name of the profile to be switched to.

Discussion

Change the bootstrap profile.

This is only used by the Authentication flow and should not be called the the application.

Declared In

EvernoteSession.h

userStore

Create a new UserStore client for EDAM calls.

- (EDAMUserStoreClient *)userStore

Return Value

Returns the user store client.

Discussion

Create a new UserStore client for EDAM calls.

This lets you make API calls to get information about the user. This function may throw an NSException. The returned object is NOT thread safe.

Declared In

EvernoteSession.h