Reputation: 25938
I want to share PDF file with Evernote in iOS application.
Note: I have found the code of Evernote login from Evernote official website but didn't get any reference of sharing PDF from anywhere.
Upvotes: 1
Views: 193
Reputation: 25938
I have found solution of my above question :
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"pdf-sample" ofType:@"pdf"];
NSData *pdfFileData = [NSData dataWithContentsOfFile:filePath];
ENResource * resource = [[ENResource alloc] initWithData:pdfFileData mimeType:@"application/pdf" filename:@"pdf-sample.pdf"];
ENNote * note = [[ENNote alloc] init];
note.title = @"Costsfirst PDF file";
[note addResource:resource];
[[ENSession sharedSession] uploadNote:note notebook:nil completion:^(ENNoteRef *noteRef, NSError *uploadNoteError) {
NSString * message = nil;
if (noteRef) {
message = @"Pdf uploaded!";
} else {
message = @"Failed to upload.";
}
}];
Above code is working perfectly for me.
Upvotes: 2
Reputation: 1964
If I do understand your question then, to share PDF with Evernote from your iOS app, can be achieved via UIActivityViewController.
try this:
NSData *pdfFileData = [NSData dataWithContentsOfFile:pdfFilePath];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[@"Test", pdfFileData] applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:nil];
--- OR ---
NSString *str = [[NSBundle mainBundle] pathForResource:@"YourPdfFileName" ofType:@"pdf"];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[@"Test", [NSURL fileURLWithPath:str]] applicationActivities:nil];
With the code above, You could scroll over on UIActivityViewController’s share section, and use other custom share extensions like Evernote.
You didn’t have to do a thing. As a user, just click the more button to show the ones you want in the share sheet. As a developer, you don’t have to do anything to your UIActivityViewController to show custom Share and Action Extensions.
Hope this may help you.
Regarding Evernote cloud sdk for iOS: https://github.com/evernote/evernote-cloud-sdk-ios/blob/master/Getting_Started.md This document covers getting set up with the Evernote Cloud SDK for iOS, some quick examples, and some discussion of the primary classes.
Upvotes: 1