README.md

[Deprecated] Evernote SDK for iOS version 1.3.1

Read Me First!

If you are beginning a new integration with Evernote, please start with the newer Cloud SDK for iOS located here. It makes the most common integrations very easy, and still offers access to the full Evernote API.

What this is

A pleasant iOS-wrapper around the Evernote Cloud API (v1.25), using OAuth for authentication.

Add the header file to any file that uses the Evernote SDK

Modify your AppDelegate

First you set up the shared EvernoteSession, configuring it with your consumer key and secret.

The SDK now supports the Yinxiang Biji service by default. Please make sure your consumer key has been activated for the China service.

Do something like this in your AppDelegate's application:didFinishLaunchingWithOptions: method.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Initial development is done on the sandbox service
// Change this to BootstrapServerBaseURLStringUS to use the production Evernote service
// Change this to BootstrapServerBaseURLStringCN to use the Yinxiang Biji production service
// Bootstrapping is supported by default with either BootstrapServerBaseURLStringUS or BootstrapServerBaseURLStringCN
// BootstrapServerBaseURLStringSandbox does not support the Yinxiang Biji service
NSString *EVERNOTE_HOST = BootstrapServerBaseURLStringSandbox;
// Fill in the consumer key and secret with the values that you received from Evernote
// To get an API key, visit http://dev.evernote.com/documentation/cloud/
NSString *CONSUMER_KEY = @"your key";
NSString *CONSUMER_SECRET = @"your secret";
// set up Evernote session singleton
[EvernoteSession setSharedSessionHost:EVERNOTE_HOST
consumerKey:CONSUMER_KEY
consumerSecret:CONSUMER_SECRET];
}

Do something like this in your AppDelegate's application:openURL:sourceApplication:annotation: method

Do something like this in your AppDelegate's applicationDidBecomeActive: method

- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
[[EvernoteSession sharedSession] handleDidBecomeActive];
}

Calling authenticateWithViewController:completionHandler: will start the OAuth process. EvernoteSession will open a new modal view controller, to display Evernote's OAuth web page and handle all the back-and-forth OAuth handshaking. When the user finishes this process, Evernote's modal view controller will be dismissed.

Use EvernoteNoteStore and EvernoteUserStore for asynchronous calls to the Evernote API

Both EvernoteNoteStore and EvernoteUserStore have a convenience constructor that uses the shared EvernoteSession.
All API calls are asynchronous, occurring on a background GCD queue. You provide the success and failure callback blocks.
E.g.,

Creating note content

The SDK includes an ENML writer that helps you write notes. This is useful to write styled notes,supports adding resources like images to the note and also supports writing encrypted fields to Evernote.
E.g.,

Handling expired Authentication tokens

You should check for expired auth tokens and trigger authentication again if the authentication token is expired or revoked by the user.

You can check for expired using if(EvernoteSession isTokenExpiredWithError:error]) in the error block.

FAQ

Does the Evernote SDK support ARC?

Yes. To use the SDK in a non-ARC project, please use the -fobjc-arc compiler flag on all the files in the Evernote SDK.

What if I want to do my own Evernote Thrift coding?

EvernoteNoteStore and EvernoteUserStore are an abstraction layer on top of Thrift, and try to keep some of that nastiness out of your hair.
You can still get access to the underlying Thrift client objects, though: check out EvernoteSession's userStore and noteStore properties.