iamdavidlam
iamdavidlam

Reputation: 404

Accessing Tags on Evernote SDK

I have successfully downloaded a Note with the following snippet found in the sample project.

[[ENSession sharedSession] downloadNote:self.noteRef progress:^(CGFloat progress) {
    if (self.webView) {

    }
} completion:^(ENNote *note, NSError *downloadNoteError) {
    if (note && self.webView) {
        self.note = note;
        NSLog(@"%@", self.note.title);
        NSLog(@"%@", self.note.sourceUrl);

        NSLog(@"%lu", self.note.EDAMNote.tagNames.count);
        NSLog(@"%lu", self.note.tagNames.count);
        [self loadWebDataFromNote:note];
    } else {
        NSLog(@"Error downloading note contents %@", downloadNoteError);
    }
}];

While the title is correct, the tagNames array returned as nil.

Is there no way to retrieve tagNames based on notes?

Cheers

Upvotes: 0

Views: 154

Answers (2)

Ciprian Rarau
Ciprian Rarau

Reputation: 3120

You could use the code below to get the list of tag guid.

ENSession * session = [ENSession sharedSession];
ENNoteStoreClient * noteStoreClient = [session noteStoreForNoteRef:noteRef];
[noteStoreClient getNoteWithGuid:noteRef.guid withContent:YES withResourcesData:NO withResourcesRecognition:NO withResourcesAlternateData:NO success:^(EDAMNote *note) {
    NSLog(@"tags guids: %@", note.tagGuids);
} failure:^(NSError *error) {

}];

Then get the list of Evernote tags and get their names.

Upvotes: 1

giftederic
giftederic

Reputation: 659

My name is Eric Cheng. I'm the lead engineer on Evernote iOS SDK

Read this https://github.com/evernote/evernote-cloud-sdk-ios/blob/master/evernote-sdk-ios/ENSDK/ENNote.h#L57-L63

I provided the ENNote class to act as a simplified version of EDAMNote, which is the thrift class representative for an Evernote note. ENNote does simple things and makes it much easier for developers to understand. If you want to read tags on a note, you should use the EDAM APIs, which is listed here https://github.com/evernote/evernote-cloud-sdk-ios/blob/master/evernote-sdk-ios/ENSDK/Advanced/ENNoteStoreClient.h#L518-L528

You can write code like this:

ENSession * session = [ENSession sharedSession];
ENNoteStoreClient * noteStoreClient = [session noteStoreForNoteRef:noteRef];
[noteStoreClient getNoteTagNamesWithGuid:noteRef.guid success:^(NSArray *tags) {
        NSLog(@"Tag count: %@", [tags count]);
  } failure:^(NSError *error) {
        NSLog(@"Error in fetching tags %@ for note guid %@", error, noteRef.guid);
}];

Upvotes: 2

Related Questions