iOS上的Facebook共享对话框:“发布”按钮总是灰色 [英] Facebook Share Dialog on iOS: "Publish" button always greyed out

查看:370
本文介绍了iOS上的Facebook共享对话框:“发布”按钮总是灰色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Facebook开发者网站上创建了一个自定义的开放图形对象,动作和故事,然后按照教程,通过官方的FB应用程序发布(没有登录到应用程序)。这是代码:

  NSMutableDictionary< FBGraphObject> *目的; 
NSString * returnUrl = [NSString stringWithFormat:@http://tettomante.it/questions?%@,
[NSString stringWithURLParams:@ {@answer:_answerLabel.text,@divination :[self divinationNickname]}]];

object = [FBGraphObject openGraphObjectForPostWithType:@boobs-teller:question
title:_questionTextView.text
image:@https://d1rdorpdffwq56.cloudfront.net/icona_tettomante .jpg
url:returnUrl
描述:_answerLabel.text];

NSMutableDictionary< FBOpenGraphAction> * action =(NSMutableDictionary< FBOpenGraphAction> *)[FBGraphObject openGraphActionForPost];
动作[@question] = object;

//检查是否安装了Facebook应用程序,我们可以显示共享对话框
FBOpenGraphActionShareDialogParams * params = [[FBOpenGraphActionShareDialogParams alloc] init];
params.action = action;
params.actionType = @boobs-teller:ask;
params.previewPropertyName = @question;

//如果安装了Facebook应用程序,我们可以显示共享对话框
if([FBDialogs canPresentShareDialogWithOpenGraphActionParams:params]){
//显示共享对话框
[FBDialogs presentShareDialogWithOpenGraphActionParams:params
clientState:nil
handler:^(FBAppCall * call,NSDictionary * results,NSError * error){
if(error){
// There是一个错误
NSLog(@错误发布故事:%@,error.description);
}
else {
// Success
NSLog(@result%@,results);
}
}];
}

问题是,一旦在FB应用程序中,自定义故事预览正确显示,大约10秒钟后消失,而顶部的发布按钮被禁用(灰色),并且不启用自身。我不明白发生了什么我认为这可能是因为应用程序处于沙箱模式(我正在使用管理员用户,所以不应该有重要的),所以我把它公开,但没有改变。然后我以为我不得不让FB审查自定义的动作,所以我已经整理了,但没有改变。现在我不知道接下来要尝试什么。

解决方案

在创建新应用程序时,我遇到了同样的问题。 Open Graph标签必须完全正确,否则您将无法发布您的故事。



检查以确保在Facebook应用程序中创建的对象和操作仪表板匹配您在代码中列出的内容。

  object = [FBGraphObject openGraphObjectForPostWithType:@boobs-teller:question

在这一行中,boobs-teller应该是你应用程序命名空间中列出的(Facebook Apps>设置>基本),问题应该是您在应用程序信息中心中创建的自定义对象(打开图形>对象类型)。如果您尚未创建这些,请访问: https://developers.facebook.com/apps

  params.actionType = @boobs-teller:ask; 

在这一行中,boobs-teller应该是你的app命名空间,ask是您在应用程序信息板中创建的自定义操作(打开图形>动作类型)。



更多详细信息在这里: https://developers.facebook.com/docs/ios/open-graph/



您也可以在GitHub上检查iOS应用程序,当学习Open Graph时,FBOGSampleSD应用程序帮助我了很多。 https://github.com/fbsamples/ios-howtos


I have created a custom open graph object, action and story on Facebook developer website, then followed the tutorial to be able to post it through the official FB app (without login in the app). This is the code:

NSMutableDictionary<FBGraphObject> *object;
NSString *returnUrl = [NSString stringWithFormat:@"http://tettomante.it/questions?%@",
                       [NSString stringWithURLParams:@{@"answer": _answerLabel.text, @"divination": [self divinationNickname]}]];

object = [FBGraphObject openGraphObjectForPostWithType:@"boobs-teller:question"
                                                 title:_questionTextView.text
                                                 image:@"https://d1rdorpdffwq56.cloudfront.net/icona_tettomante.jpg"
                                                   url:returnUrl
                                           description:_answerLabel.text];

NSMutableDictionary<FBOpenGraphAction> *action = (NSMutableDictionary<FBOpenGraphAction> *) [FBGraphObject openGraphActionForPost];
action[@"question"] = object;

// Check if the Facebook app is installed and we can present the share dialog
FBOpenGraphActionShareDialogParams *params = [[FBOpenGraphActionShareDialogParams alloc] init];
params.action = action;
params.actionType = @"boobs-teller:ask";
params.previewPropertyName = @"question";

// If the Facebook app is installed and we can present the share dialog
if([FBDialogs canPresentShareDialogWithOpenGraphActionParams:params]) {
    // Show the share dialog
    [FBDialogs presentShareDialogWithOpenGraphActionParams:params
                                               clientState:nil
                                                   handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
                                                       if(error) {
                                                           // There was an error
                                                           NSLog(@"Error publishing story: %@", error.description);
                                             }
                                                       else {
                                                           // Success
                                                           NSLog(@"result %@", results);
                                                       }
                                                   }];
}

The problem is that once in the FB app the custom story preview appears correctly and after about 10 seconds disappears, while the "Publish" button on the top is disabled (greyed out) and doesn't enable itself. I don't understand what's going on. I thought that could be because the app was in sandbox mode (I was using the administrator user so that shouldn't have mattered), so I made it public but nothing changed. Then I thought I had to make FB review the custom action, so I had that sorted out also, but nothing has changed. Now I don't know what to try next.

解决方案

I had the same issue while creating a new app. The Open Graph tags have to be exactly correct, or you won't be able to publish your story.

Check to make sure the objects and actions created in the Facebook app dashboard match what you have listed in the code.

object = [FBGraphObject openGraphObjectForPostWithType:@"boobs-teller:question"

In this line, "boobs-teller" should be what you have listed as your App's namespace(Facebook Apps > Settings > Basic), and "questions" should be the custom Object (Open Graph > Object Types) you created in the App dashboard. If you haven't created these yet, go here: https://developers.facebook.com/apps

params.actionType = @"boobs-teller:ask";

In this line, "boobs-teller" should be your app namespace, and "ask" is the custom Action (Open Graph > Action Types) you created in the app dashboard.

More details are here: https://developers.facebook.com/docs/ios/open-graph/

You can also check the sample iOS apps on GitHub, the FBOGSampleSD app helped me out a lot while learning Open Graph. https://github.com/fbsamples/ios-howtos

这篇关于iOS上的Facebook共享对话框:“发布”按钮总是灰色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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