有时,当我启动 Facebook 共享对话框时,操作系统会切换到 Facebook 应用程序,但不会加载共享对话框。然后,如果您再试一次,它通常会起作用。为什么第一次就不行?
NSURL* url = [NSURL URLWithString:@"some URL"];
FBShareDialogParams* params = [[FBShareDialogParams alloc] init];
params.link = url;
if ([FBDialogs canPresentShareDialogWithParams:params]) {
[FBDialogs presentShareDialogWithLink:url
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
NSLog(@"Error posting to FB: %@", error.description);
//do something
} else {
//do something else
}
}];
// }
}