简体   繁体   中英

Facebook send dialog in iOS app

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
}];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM