rld*_*001 9 facebook ios xcode6 ios8
我想在我的iOS应用程序中与FBSDK建立Facebook共享.
我一直在这里阅读文档,目前已有
[FBSDKShareDialog showFromViewController:self withContent:content delegate:self];
Run Code Online (Sandbox Code Playgroud)
使用内容对象 - FBSDKShareLinkContent.
但是,在尝试使用Facebook Messenger共享指定的类似方法时,
[FBSDKMessageDialog showWithContent:content delegate:self];
Run Code Online (Sandbox Code Playgroud)
我正在崩溃.我发现错误并将其记录在其中一个委托方法中,并指出"操作无法完成.(com.facebook.sdk.share error 202.)"
我搜索了这个特定的错误,但没有找到任何直接相同的错误.这是完整的代码
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:kAPPShareLink];
content.contentDescription = kAPPShareDescription;
content.contentTitle = kAPPShareTitle;
if (buttonIndex == 0) {
// Facebook
[FBSDKShareDialog showFromViewController:self withContent:content delegate:self];
} else if (buttonIndex == 1) {
// Facebook Messenger
[FBSDKMessageDialog showWithContent:content delegate:self];
}
Run Code Online (Sandbox Code Playgroud)
请原谅我,如果我遗漏了一些明显的东西,但正如本文档所述,我认为该FBSDKMessageDialog showWithContent:方法的工作方式与FBSDKShareDialog showFromViewController:我的工作方式相同.
我必须登录然后发布,这是它的工作原理:
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
{
if (error)
{
// Process error
}
else if (result.isCancelled)
{
// Handle cancellations
}
else
{
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:@"https://developers.facebook.com/"];
FBSDKMessageDialog *messageDialog = [[FBSDKMessageDialog alloc] init];
messageDialog.delegate = self;
[messageDialog setShareContent:content];
if ([messageDialog canShow])
{
[messageDialog show];
}
else
{
// Messenger isn't installed. Redirect the person to the App Store.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/en/app/facebook-messenger/id454638411?mt=8"]];
}
}
}];
Run Code Online (Sandbox Code Playgroud)
和股份代表:
- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results
{
NSLog(@"didCompleteWithResults");
}
- (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError ::: %@" , error);
}
- (void)sharerDidCancel:(id<FBSDKSharing>)sharer
{
NSLog(@"sharerDidCancel");
}
Run Code Online (Sandbox Code Playgroud)
编辑:
[messageDialog canShow]在iPad上返回NO,在iPhone上运行正常
在Facebook开发者论坛上发布了这个问题.
小智 1
注意:这更适合作为评论,但我还没有足够的声誉来发表评论
我遇到同样的错误,Facebook 和 Messenger 都更新了。
我检查了我的权限
[[FBSDKAccessToken currentAccessToken] permissions]
Run Code Online (Sandbox Code Playgroud)
我想我已经足够了:
"contact_email",
"publish_stream",
"user_likes",
"publish_checkins",
"video_upload",
"create_note",
"basic_info",
"publish_actions",
"public_profile",
"photo_upload",
"status_update",
email,
"user_friends",
"share_item"
Run Code Online (Sandbox Code Playgroud)
我尝试了与OP相同的方法,并且我也尝试过:
FBSDKMessageDialog *messageDialog = [[FBSDKMessageDialog alloc] init];
[messageDialog setShareContent:content];
messageDialog.delegate = self;
if ([messageDialog canShow]) {
[messageDialog show];
}
Run Code Online (Sandbox Code Playgroud)
[messageDialog canShow]返回NO,并且委托方法捕获失败并出现 OP 描述的 202 错误。
我尝试使用 FBSDKSendButton,但似乎也不起作用。
另一方面,FBSDKShareDialog 工作得很好......
我希望这有助于解决问题。
| 归档时间: |
|
| 查看次数: |
3350 次 |
| 最近记录: |