iOS无法在Facebook上发布,未记录任何错误
我正在尝试使用他们iOS游戏教程中的代码与Facebook共享。对话框弹出,我指定的图像和文本出现,但当我点击“发送”时,加载栏出现,没有加载,然后我被重定向到我的应用程序。控制台上不会打印任何错误,应用程序也不会崩溃 当我在Facebook上查看消息是否已发布时,我得到以下信息: “哎呀,出现了问题。发布您的状态时出现问题。我们已记录了错误,将对此进行调查。” 我在以前的应用程序中使用过这段代码,它运行得非常好。我已经在plist中更新了Facebook ID、Facebook显示名和URL方案 代码如下: FacebookHandler类(源自Facebook教程) 我的电话iOS无法在Facebook上发布,未记录任何错误,ios,facebook,facebook-sharer,Ios,Facebook,Facebook Sharer,我正在尝试使用他们iOS游戏教程中的代码与Facebook共享。对话框弹出,我指定的图像和文本出现,但当我点击“发送”时,加载栏出现,没有加载,然后我被重定向到我的应用程序。控制台上不会打印任何错误,应用程序也不会崩溃 当我在Facebook上查看消息是否已发布时,我得到以下信息: “哎呀,出现了问题。发布您的状态时出现问题。我们已记录了错误,将对此进行调查。” 我在以前的应用程序中使用过这段代码,它运行得非常好。我已经在plist中更新了Facebook ID、Facebook显示名和URL方
#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,它不会发布。我通过手动在plist文件中键入“URL类型”键来修复它。
不要复制粘贴另一个plist文件中的plist值-这是苹果的bug当它在模拟器中运行良好时,我也面临这个问题。到目前为止有解决方案吗?我也有同样的问题。