presentShareDialogWithParams发布到FB墙,但回调处理程序结果说错误 [英] presentShareDialogWithParams posts to FB wall, but callback handler results say error

查看:118
本文介绍了presentShareDialogWithParams发布到FB墙,但回调处理程序结果说错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iOS应用程序与Facebook SDK。我在 https://使用第一个示例代码块developers.facebook.com/docs/ios/ios-sdk-games/feed/ 几乎逐字地将我的应用程序信息分享到FB。我只改变了示例代码中的字符串和URL,以适应我的应用程序。



虽然我的应用程序的帖子确实出现在我的Facebook墙上,一切都看起来不错,FBAppCall导致我的 NSLog 正在说,


错误发布故事=错误Domain = com .facebook.sdk Code = 11
用户在完成这个
AppCall之前从Facebook应用程序导航。此AppCall现在已被取消,需要重试才能获得
a成功完成


我正在尝试使用FBAppCall结果,以便在成功发送后,我可以触发另一个网络呼叫到我的后端,我可以记录奇怪的是,虽然我可以看到我墙上的帖子,但Story Published的最终 else 条件没有发生,



以下是从 https://developers.facebook.com/docs/ios/ios-sdk-games/feed/

  [FBDialogs presentShareDialogWithParams:shareParams 
clientState:nil
处理程序:^(FBAppCall *调用,NSDictionary *结果,NSError *错误){
if(error){
NSLog(@Error publishing story =%@。,error);
NSLog(@result =%@。,results);
} else if(results [@completionGesture]&& [results [@completionGesture] isEqualToString:@cancel]){
NSLog(@用户已取消故事发布。 );
} else {
NSLog(@发布故事);
self.shareMethod = @Facebook;
[self recordSharingDataAtParse:self.shareMethod];
}
}];

最后一个注意事项:我不相信可能是原因,但我的FB应用程序在沙盒模式目前。



更新:我发现这个类似的帖子 FBDialogs presentShareDialogWithParams成功但错误得到返回,建议解决方案禁用Install Insights& 移动SDK洞察在应用程序控制台。



谢谢。

解决方案

当您遇到此错误时,您将需要处理应用程序代理的响应。

   - (BOOL)应用程序:(UIApplication *)应用程序
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
注释:(id)注释
{
return [FBAppCall handleOpenURL:url
sourceApplication:sourceApplication
fallbackHandler:^(FBAppCall * call){
if(call.appLinkData&&& call.appLinkData.targetURL){
// Invoke pending callback。
}
}];
}

当用户完成操作时,该呼叫将包含所有来自帖子:

 < FBAppCall:0x147274f0,ID:62FA2382-B557-45D5-8ACA-FE4C7516F861 
dialogData:< ; FBDialogsData:0x14727490,方法:share
arguments:{
dataFailuresFatal = 0;
description =经过多年的囚禁,愤怒的山羊终于免费了!
link =http://appstore.com/berrycrush;
name =解开的愤怒的山羊;
picture =http://example.com/angry-goat.png;
}
结果:{
completionGesture = post;
didComplete = 1;
}>
>


I've got an iOS app with the Facebook SDK. I'm using the first block of sample code at https://developers.facebook.com/docs/ios/ios-sdk-games/feed/ almost verbatim to share info from my app to FB. I've only changed strings and URLs from the sample code to fit my app.

While posts from my app do appear on my Facebook wall and everything looks good, the FBAppCall results in my NSLog are saying,

Error publishing story = Error Domain=com.facebook.sdk Code=11 "The user navigated away from the Facebook app prior to completing this AppCall. This AppCall is now cancelled and needs to be retried to get a successful completion

I'm trying to use the FBAppCall results so that upon a successful send, I can trigger another network call to my backend where I can record data about the event. Oddly, while I can see the posts on my wall, the final else condition of "Story Published" is not occurring, the error condition is.

Here's the actual FBAppCall that again comes right from https://developers.facebook.com/docs/ios/ios-sdk-games/feed/

[FBDialogs presentShareDialogWithParams:shareParams
                                clientState:nil
                                    handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
                                        if(error) {
                                            NSLog(@"Error publishing story = %@.", error);
                                            NSLog(@"result = %@.", results);
                                        } else if (results[@"completionGesture"] && [results[@"completionGesture"] isEqualToString:@"cancel"]) {
                                            NSLog(@"User canceled story publishing.");
                                        } else {
                                            NSLog(@"Story published.");
                                            self.shareMethod = @"Facebook";
                                            [self recordSharingDataAtParse:self.shareMethod];
                                        }
                                    }];

One last note: I don't believe it could be the cause, but my FB app is in "sandbox" mode currently.

Update: I found this similar post FBDialogs presentShareDialogWithParams succeeds but error gets returned with recommended resolution of disabling "Install Insights" & "Mobile SDK Insights" in the app console. Unfortunately that did not resolve my issue.

Thanks.

解决方案

When you encounter this error, you will need to handle the response from your app delegate.

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation
{
    return [FBAppCall handleOpenURL:url
                  sourceApplication:sourceApplication
                    fallbackHandler:^(FBAppCall *call) {
                        if (call.appLinkData && call.appLinkData.targetURL) {
                            // Invoke pending callback. 
                        }
                    }];
}

When the user completes the action, the call would contain all the information from the post:

<FBAppCall: 0x147274f0, ID: 62FA2382-B557-45D5-8ACA-FE4C7516F861
 dialogData: <FBDialogsData: 0x14727490, method: share
 arguments: {
    dataFailuresFatal = 0;
    description = "After years of captivity, Angry Goat is finally free!";
    link = "http://appstore.com/berrycrush";
    name = "Unlocked Angry Goat";
    picture = "http://example.com/angry-goat.png";
}
 results: {
    completionGesture = post;
    didComplete = 1;
}>
>

这篇关于presentShareDialogWithParams发布到FB墙,但回调处理程序结果说错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆