Facebook Share Dialog on iOS: “Publish” button always greyed out

别说谁变了你拦得住时间么 提交于 2020-01-13 17:02:42

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/21552944/facebook-share-dialog-on-ios-publish-button-always-greyed-out

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