iOS未能在Facebook上发布,没有记录错误 [英] iOS failure to post on Facebook, no errors logged

查看:154
本文介绍了iOS未能在Facebook上发布,没有记录错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用iOS游戏教程中的代码分享给Facebook。对话框弹出,我指定的图像和文本存在,但是当我点击发送时,出现加载栏,不加载,然后我被重定向到我的应用程序。没有错误打印到控制台,应用程序不会崩溃。

I'm trying to share to Facebook using code from their iOS game tutorial. The dialog pops up and the image and text I specified is present, but when I hit "Send" the loading bar appears, doesn't load, then I am redirected to my app. No errors are printed to the console and the app does not crash.

当我在Facebook上查看邮件是否已发布时,我得到以下内容:

When I go on Facebook to check if the message has posted, I get the following:

糟糕,有些事情错了,发布你的状态有一个问题,我们已经记录错误,并会调查。

"Oops, Something Went Wrong. There was a problem posting your status. We've logged the error and will look into it."

我在以前的应用程序中使用了这个代码,它工作得很好。我已经在plist中更新了Facebook ID,Facebook显示名称和URL方案。

I've used this code in the previous app and it worked perfectly fine. I've updated the Facebook ID, Facebook Display Name, and URL Scheme in the plist.

这是代码:

FacebookHandler类(派生自Facebook教程)

#import "FacebookHandler.h"

@implementation FacebookHandler

+ (void) Facebook_CreateNewSession
{
    // initialize Facebook
    FBSession* session = [[FBSession alloc] init];
    [FBSession setActiveSession: session];
}

+ (void) Facebook_Login
{
    NSArray *permissions = [[NSArray alloc] initWithObjects:
                        @"email",
                        nil];

// Attempt to open the session. If the session is not open, show the user the Facebook login UX
[FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:true completionHandler:^(FBSession *session, FBSessionState status, NSError *error)
{
    // Did something go wrong during login? I.e. did the user cancel?
    if (status == FBSessionStateClosedLoginFailed || status == FBSessionStateCreatedOpening) {

        // If so, just send them round the loop again
        [[FBSession activeSession] closeAndClearTokenInformation];
        [FBSession setActiveSession:nil];
        [self Facebook_CreateNewSession];
    }
    else
    {
    }                  
}];
}

+ (void) Facebook_PostToNewsFeedWithTitle:(NSString*)title withCaption:(NSString*)caption withDescription:(NSString*)description withLink:(NSString*)link withPictureURL:(NSString*)picURL
{

// check if user is logged in
if ([FBSession activeSession] == nil)
{
    [FacebookHandler Facebook_CreateNewSession];
    [FacebookHandler Facebook_Login];
}


// This function will invoke the Feed Dialog to post to a user's Timeline and News Feed
// It will attemnt to use the Facebook Native Share dialog
// If that's not supported we'll fall back to the web based dialog.

NSString *linkURL = link;
NSString *pictureURL = picURL;

// Prepare the native share dialog parameters
FBShareDialogParams *shareParams = [[FBShareDialogParams alloc] init];
shareParams.link = [NSURL URLWithString:linkURL];
shareParams.name = title;
shareParams.caption= caption;
shareParams.picture= [NSURL URLWithString:pictureURL];
shareParams.description = description;

if ([FBDialogs canPresentShareDialogWithParams:shareParams]){

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

}else {

    // Prepare the web dialog parameters
    NSDictionary *params = @{
                             @"name" : shareParams.name,
                             @"caption" : shareParams.caption,
                             @"description" : shareParams.description,
                             @"picture" : pictureURL,
                             @"link" : linkURL
                             };

    // Invoke the dialog
    [FBWebDialogs presentFeedDialogModallyWithSession:nil
                                           parameters:params
                                              handler:
     ^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
         if (error) {
             NSLog(@"Error publishing story.");
         } else {
             if (result == FBWebDialogResultDialogNotCompleted) {
                 NSLog(@"User canceled story publishing.");
             } else {
                 NSLog(@"Story published.");
             }
         }}];
}
}
@end

我的电话

    [FacebookHandler Facebook_PostToNewsFeedWithTitle:title withCaption:caption withDescription:description withLink:link withPictureURL:picURL];

更新

这似乎是Facebook应用程序的一个问题。在使用Facebook卸载的设备上进行尝试时,我被要求登录,然后成功发布。但是,如果安装了Facebook,它不会发布。

It seems to be a problem with the Facebook app. When trying it on a device with Facebook uninstalled, I am asked to log in and then it posts successfully. However, if Facebook is installed, it doesn't post.

推荐答案

我通过手动修复在plist文件中键入URL类型键。
不要从另一个plist文件复制粘贴 plist值 - 这是苹果的bug !!!

I fix it by manually typing the "URL types" key at the plist file. Don't copy paste the plist values from another plist file - it's Apple's bug!!!

这篇关于iOS未能在Facebook上发布,没有记录错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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