I have an iOs app in which I tell the user to share a link with the friends he wants. I want to offer him the possibility to open a new inbox from within the app and if possible with pre-filled content. But no pre-filled recipient. And I want it to be available to all users (not only those with facebook connect).
Basically I want to replicate the following send dialog for web in the app: https://developers.facebook.com/docs/reference/dialogs/send/
Which means it will open the facebook app and not the browser to show the new inbox dialog.
From my research I found no clear solution and as it is possible from a website I would be surprised I cannot do the same with the app.
Thank you very much in advance, Jules
You can use UIActivityViewController
.
You first have to create a list of the things you want to share: an URL, a string, etc like this
NSArray *activityItems = @[[NSURL URLWithString:@"www.link-to-share.com], @"What you want written above"];
Afterwards, you just have to create the UIActivityViewController
with the things you want to share and present it modally:
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityController animated:YES completion:nil];
You can also add a completion block so that you are notified when the user is done with the sharing:
[activityController setCompletionHandler:^(NSString *activityType, BOOL completed){
//do stuff
}];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With