How to share PDF file with Evernote in iOS - ios

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.

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.

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.

Related

Is there a way to share text on facebook messenger without SDK?

Is there a way to share text on facebook messenger without SDK?
I found the following method.
-(void)shareAction:(NSString *)str param:(NSString *)strTitle
{
NSString *title = strTitle;
NSURL *url = [[NSURL alloc]initWithString:str];
NSArray *postItems = #[title, url];
UIActivityViewController *activityVC = [[UIActivityViewController alloc]
initWithActivityItems:postItems
applicationActivities:nil];
activityVC.excludedActivityTypes = #[];
[self presentViewController:activityVC animated:YES completion:nil];
}
However, not just how to select Facebook Messenger among the various apps,
I want to send it directly to Facebook Messenger.
Is there a way without the SDK?
You can use UIActivityViewController to share the app using Facebook Messenger. Please check following sample URL which will display the App list which have implemented share extension.
http://pinkstone.co.uk/how-to-share-things-with-a-uiactivityviewcontroller/

How to send contact (.vcf) file via UIActivityViewController in iOS

I make one app. App generate “ .vcf ” and you want to send that vcf to everyone. My option is send it through email , whatsapp ,and other share apps, and i use UIActivityViewController, but it can’t send whatsapp. I can send image ,video , audio but i can’t send contact. Please help me to solve this problem. I refere this link and do that thing same as mention but same problem occurred.
Thanks in advance.
Here is my code.
Here you check i send every thing image ,audio, video but not able to send contact. So help me.
-(void)shareContact
{
//NSString *str = [[NSBundle mainBundle] pathForResource:#"HAK" ofType:#".mp3"];
//NSString *str = [[NSBundle mainBundle] pathForResource:#"b" ofType:#"png"];
//NSString *str = [[NSBundle mainBundle] pathForResource:#"Movie" ofType:#".mp4"];
NSString *str = [[NSBundle mainBundle] pathForResource:#"vCard" ofType:#".vcf"];
//NSString *str = [self vCardRepresentation];
NSURL *fileUrl = [NSURL fileURLWithPath:str];
NSArray *objectsToShare = #[fileUrl];
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
[self presentViewController:controller animated:YES completion:nil];
}

Send NSData via Airdrop

I've got a (for me) big problem.
I want to send a vcf-file with airdrop from my own app to another iOS device. I've got a NSData object, which i should convert to a vcf file, and this I should send with airdrop to another IOS device.
The NSData object works fine, i can send a vcc file with email, but with airdrop I left my limit.
I tried everything i found here in the forum and on developer.apple.com. But nothing works, I think the reason is, that i have no idea how too start the fix the problem.
Has anybody any idea how i can realize it?
THANKS
I believe this is roughly what you are looking for:
NSString *contactName = nil; // name of person in vcard
NSData *vcfData = nil; // vcard data
NSURL *fileURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:#"%#.vcf", contactName]]];
NSError *writeError;
if ([vcfData writeToURL:fileURL options:NSDataWritingAtomic error:&writeError]) {
NSArray *activityItems = #[fileURL];
UIActivityViewController *avc = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:avc animated:YES completion:nil];
} else {
// failed, handle errors
}
If you still want to support providing NSData to some of the activities you will have to create some objects that conforms to UIActivityItemSource protocol and have some of them return nil where appropriate (see this SO for more details on that). You might find the AirDrop sample code project from Apple helpful too.

iOS Share GIFs to Messenger using UIActivityViewController

I am trying to share different type of images using UIActivityViewController to facebook messenger. I am facing no problem while sharing the images (.png), but I am not able to send gif images (.gif), it is giving error "Couldn't load content".
I am converting the image to data & then sending the data in array through UIActivityViewController.
Here, I am firing a notification with the details & extracting the gif path & then processing it.
NSDictionary *dictAsset = [notification userInfo];
NSData *imageData = [NSData dataWithContentsOfFile:dictAsset[#"path"]];
NSArray *imageToShare = [NSArray arrayWithObjects: imageData, [dictAsset objectForKey:#"assetName"], nil];
NSArray *arrAsset = imageToShare;
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:arrAsset applicationActivities:nil];
Has anyone faced same issue? or if anyone has a solution then please help me out.
iOS does not consider a GIF an image. You have to instead share it as a file:
NSURL *gifFile = [NSURL fileURLWithPath:#"funnyface.gif"];
NSArray *items = #[gifFile];
[[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];

Not able to share URL on Facebook and Twitter using UIActivityViewController in iOS 7.1

I am using UIActivityViewController for share button.It's showing text and url when I am selecting mail option from list but it's showing only text not url when I am selecting Facebook or Twitter.I searched a lot but not getting solution for my issue.I got one more solution to add "http" in url but is this possible without adding http in url. My code is -
NSArray *activityItems;
NSString *str;
NSString *noteStr;
str = [NSString stringWithFormat:#"com.boxscoregames.squares://square?%#",squareID];
noteStr = #"You have been invited to join the Square game, please follow the link below on your iPhone.";
NSURL *url = [NSURL URLWithString:str];
// str =[NSString stringWithFormat:#"<html>%#</html>" ,str,str];
activityItems = #[noteStr,url];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];
I believe the link is indeed not being shown. But, when you post it, the link will be added to your Facebook/twitter post.
You could of course just also add the link to the text.
NSString *link = [NSString stringWithFormat:#"com.boxscoregames.squares://square?%#",squareID];
NSString *noteStr = [NSString stringWithFormat:#"You have been invited to join the Square game, please follow the link below on your iPhone. %#", link];
NSURL *url = [NSURL URLWithString:link];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:#[noteStr, url] applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];

Resources