Adi Greenvald
Adi Greenvald

Reputation: 196

createNote using Evernote API

EvernoteNoteStore *noteStore = [EvernoteNoteStore noteStore];
EDAMNote *note = [[EDAMNote alloc] init];
[note setTitle:@"Test Note from EvernoteCounter for iPhone"];
[note setContent:[ [NSString alloc] initWithFormat:@"<en-note>%@</en-note>",@"tete"];
[noteStore createNote:(note) success:^(EDAMNote *note) {
    NSLog(@"Received note guid: %@", [note guid]);
}failure:^(NSError *error) {
    NSLog(@"Create note failed: %@", error);
}];

I used this code to activate createNote by evernote, but createNote doesn't return any value - it's stuck in one of the inner API functions called async. Has anyone tried to create a new note using the API on iOS's SDK and actually got the note on their Evernote account?

Upvotes: 3

Views: 1123

Answers (2)

Long Pham
Long Pham

Reputation: 7582

Sample code for u. @KatieK
// --------------------------------

EvernoteNoteStore *noteStore = [EvernoteNoteStore noteStore];
    EDAMNote *note = [[EDAMNote alloc] init];
    [note setTitle:@"Hello Evernote"];
    [note setContent:[[NSString alloc] initWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\"><en-note>Hello, world! %@</en-note>",@"I'm LongPham"]];


    [noteStore createNote:note success:^(EDAMNote *note) {
        NSLog(@"Received note guid: %@", [note guid]);
    }failure:^(NSError *error) {
        NSLog(@"Create note failed: %@", error);
    }];

Upvotes: 0

Mustafa
Mustafa

Reputation: 5347

We just added some new sample code to create a photo note. Please check it out : https://github.com/evernote/evernote-sdk-ios. The right way to create a note is using:

- (id) initWithGuid: (EDAMGuid) guid title: (NSString *) title content: (NSString *) content contentHash: (NSData *) contentHash contentLength: (int32_t) contentLength created: (EDAMTimestamp) created updated: (EDAMTimestamp) updated deleted: (EDAMTimestamp) deleted active: (BOOL) active updateSequenceNum: (int32_t) updateSequenceNum notebookGuid: (NSString *) notebookGuid tagGuids: (NSArray *) tagGuids resources: (NSArray *) resources attributes: (EDAMNoteAttributes *) attributes tagNames: (NSArray *) tagNames;

Also see : http://dev.evernote.com/documentation/reference/Types.html#Struct_Note for more info.

Upvotes: 0

Related Questions