gpt4 book ai didi

ios - FBDialogs canPresentMessageDialogWithParams 返回 false

转载 作者:可可西里 更新时间:2023-11-01 04:57:39 25 4
gpt4 key购买 nike

我目前正在尝试将 Facebook SDK 添加到我的应用程序的 iOS 版本中。登录、注销、共享和请求功能目前都在工作,但我很难让 MessageDialog 功能工作。我的设备上目前安装了 Facebook 应用程序和 Facebook Messenger 应用程序。但是,每次我调用“FBDialog canPresentMessageDialogWithParams:params”时,它都会返回 false。

我的猜测是当应用程序仍处于开发模式时此功能不起作用,但这只是一个猜测。有谁知道消息对话框是否适用于正在开发的应用程序?或者您对我做错了什么有任何想法?

我还包含了我的代码,以防我犯任何愚蠢的错误。非常感谢任何帮助!

// Check if the Facebook app is installed and we can present the share dialog
FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
params.link = [NSURL URLWithString:@"https://www.facebook.com/"];
params.name = @"Flash Bear";
params.caption = nil;
params.picture = nil;
params.linkDescription = @"I'm playing Flash Bear. Why don't you come join me?";


// If the Facebook Messenger app is installed and we can present the share dialog
if ([FBDialogs canPresentMessageDialogWithParams:params]) {
// Present message dialog


[FBDialogs presentMessageDialogWithParams:params
clientState:nil
handler: ^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(@"Error messaging link: %@", error.description);
} else {
// Success
NSLog(@"result %@", results);
}
}];
} else {
// Present the feed dialog
// Put together the dialog parameters

UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Sorry!"
message:@"There was an error connecting to FB Messenger. Please make sure that it is installed."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message show];

}

最佳答案

我的申请也遇到了同样的问题。

我通过检查事件 session 状态解决了这个问题。如果事件 session 的状态不是打开,那么我们需要再次打开 session 。

要执行相同的操作,请使用以下代码。

if([FBSession activeSession].state != FBSessionStateOpen){

BOOL result = [FBSession openActiveSessionWithAllowLoginUI:NO];
if(result)
{
//Do your stuff here
}
}

祝你好运。

关于ios - FBDialogs canPresentMessageDialogWithParams 返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25355164/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com