Facebook SDK 3.1 presentShareDialogModally fails

江枫思渺然 提交于 2019-12-01 05:21:05

问题


I'm trying to test out the new built-in share "sheet" for Facebook on iOS 6 but when I run the sample code it doesn't show the sheet. Instead it posts a status for me without showing what it's going to post first. Also I thought Facebook didn't allow you to put words in the user's mouth anymore? The console prints this error: HelloFacebookSample Error: HTTP status code: 400

I have XCode 4.5 and iOS simulator 6.0 and Facebook SDK 3.1

I'm following this: http://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/3.1/


回答1:


Did you set up the Facebook account on the device/simulator (under Settings->Facebook)?

The native sheet dialogs are only presented when the app is running on ios 6 AND the user is authenticated through the ios 6 Facebook account. Otherwise, the handler does report that error and the presentShareDialogModallyFrom returns "NO". Also, the FBNativeDialogResult result in the handler will equal FBNativeDialogResultError.




回答2:


You are missing some of the required frameworks:

AdSupport.framework

Account.framework

Social.framework

BOOL displayedNativeDialog =
[FBNativeDialogs
 presentShareDialogModallyFrom:self
 initialText:self.shareText
 image:nil
 url:nil
 handler:^(FBNativeDialogResult result, NSError *error) {
     if (error) {
         /* handle failure */
         NSLog(@"error:%@, %@", error, [error localizedDescription]);
     } else {
         if (result == FBNativeDialogResultSucceeded) {
             /* handle success */
             NSLog(@"handle success");
         } else {
             /* handle user cancel */
             NSLog(@"user cancel");
         }
     }
 }];
if (!displayedNativeDialog) {
    /* handle fallback to native dialog  */
}



回答3:


Make sure you're not opening sessions using deprecated methods (ie.openActiveSessionWithPermissions instead of the newer openActiveSessionWithReadPermissions/openActiveSessionWithWritePermissions) or the facebook sdk won't use native facebook integration (ie. native dialogs)



来源:https://stackoverflow.com/questions/12592898/facebook-sdk-3-1-presentsharedialogmodally-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!