This library is a wrapper of Evernote API.
- ARC enabled project.
- I did not implemented all of evernote API, only what I needed. check out EvernoteRequest.h.
I don't want to store username and password in our app.
(I don't need dialog, supports only oauth using safari for multitasking ios)
//synchronous
- (EDAMNote*)createNoteInNotebook:(EDAMNotebook *)notebook
title:(NSString*)title
content:(NSString*)content
tags:(NSArray *)tags
andResources:(NSArray*)resources;
//asynchronous
- (EvernoteRequest *)createNoteInNotebook:(EDAMNotebook *)notebook
title:(NSString*)title
content:(NSString*)content
tags:(NSArray *)tags
resources:(NSArray*)resources
andDelegate:(id<EvernoteRequestDelegate>)delegate;
(I haven't implemented other wrapper methods yet, but asynchronous request implementation is already in EvernoteNoteStoreClient.h)
I want to know the progress of request, implemented subclass of thrift's THTTPClient, EvernoteHTTPClient to do it. And added EvernoteRequestDelegate. Currently this feature works with asynchronous request only.
@protocol EvernoteRequestDelegate <NSObject>
@optional
- (void)requestLoading:(EvernoteRequest*)request;
- (void)request:(EvernoteRequest*)request didReceiveResponse:(NSURLResponse*)response;
- (void)request:(EvernoteRequest*)request didFailWithError:(NSError*)error;
- (void)request:(EvernoteRequest*)request didLoad:(id)result;
- (void)request:(EvernoteRequest*)request didLoadRawResponse:(NSData*)data;
- (void)request:(EvernoteRequest*)client
didSendBodyData:(NSInteger)bytesWritten
totalBytesWritten:(NSInteger)totalBytesWritten
totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
@end
1, Copy source files in EVNConnect into your project.
Libraries are stored in Libraries
-
Evernote
ARC enable version of evernote api 1.20. -
KissXML
To handle ENML. To use it, please follow instruction in Getting Started -
PDKeychainBindingsController
To save/load credential. -
RegexKitLite
To search note/notebooks/tags with pattern.
You need to add libicucore.dylib to your project. -
OAuthConsumer
To use OAuth, Security.framework and libxml2.dylib are needed. -
DigestAddition
To generate md5 hash, I forget where it comes.
#import "EVNConnect.h"
@interface MainViewController : UIViewController<EvernoteSessionDelegate, EvernoteRequestDelegate>{
__strong Evernote *evernote_;
}
@property (nonatomic, readonly) Evernote *evernote;
@end
Initialize Evernote class as below. Where EVERNOTE_CONSUMER_KEY and EVERNOTE_CONSUMER_SECRET are provided by evernote. And callbackScheme is url scheme which you configured in your project. useSandBox is flag to select http://www.evernote.com or http://sandbox.evernote.com for API endpoint.
//create instance of evernote
evernote_ =
[[Evernote alloc] initWithAuthType:EvernoteAuthTypeOAuthConsumer
consumerKey:EVERNOTE_CONSUMER_KEY
consumerSecret:EVERNOTE_CONSUMER_SECRET
callbackScheme:@"evnconnecttest://authorize"
useSandBox:YES
andDelegate:self];
If you call [evernote_ saveCredential] when previous authentication succeeded, you can load credential via calling loadCredential method. If valid credential loaded, you can call noteStore method without switching to safari to authenticate user.
[evernote_ loadCredential];
Now you can call [evernote_ login] method to login to Evernote with oauth. When there is no valid authToken saved, this method will switch to safari to authenticate user.
[evernote_ login];
You may save credential when user did login, or clear credential when login failed.
#pragma mark - EvernoteSessionDelegate
-(void)evernoteDidLogin{
[evernote_ saveCredential];
}
- (void)evernoteDidLogout{
[evernote_ clearCredential];
}
- (void)evernoteDidNotLogin{
[evernote_ clearCredential];
}
Now you can request to Evernote API. If you call asynchronous requests, you may implement EvernoteRequestDelegate to handle response from server.
//sync request
EDAMNotebook *notebook = [evernote_ notebookNamed:@"test"];
if(notebook == nil){
notebook = [evernote_ createNotebookWithTitle:@"test"];
}
EDAMResource *resource1 =
[evernote_ createResourceFromUIImage:[UIImage imageNamed:@"sample1.jpg"]];
//async request
[evernote_ createNoteInNotebook:notebook
title:@"testnote"
content:@"testnotemogemoge"
tags:[NSArray arrayWithObjects:@"Photo", @"Bear", nil]
resources:[NSArray arrayWithObject:resource1]
andDelegate:self];
Copyright (c) 2011, ISHITOYA Kentaro.
New BSD License. See LICENSE file.
-
Evernote API
Copyright (c) 2007-2011 by Evernote Corporation, All rights reserved.
Evernote API's License is here -
Apache Thrift
Apache thrift is Licensed under Apache License 2.0. You can read full text of the license here -
OAuthConsumer
OAuthConsumer is Licensed under MIT License. -
KissXML
I could not find out mention of license in their repository. -
PDKeychainBindingsController
Copyright (C) 2010-2011 by Carl Brown of PDAgent, LLC.
PDKeychainBindingsController is licensed under MIT license. You can read full text of the license here. -
RegexKitLite
Copyright © 2008-2010, John Engelhart
RegexKitLite is licensed under BSD License. You can read full text of the license here