您的位置:首页 > 大数据 > 人工智能

-canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"

2016-08-11 18:06 323 查看
Facebook SDK的相关问题

在接FB登录的时候,真机上IOS9.0之前登录都没问题,IOS9.0之后首先会有个-canOpenURL: failed for URL: “fbauth2:/” - error: “(null)”的警告,官方文档说可以忽略。

如果想去掉这个警告信息,可做如下操作:

如果使用 iOS SDK 9.0 重新编译应用,且目前的 SDK 版本为 4.5 或更低版本,请将以下内容添加到应用程序的 plist:

<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string>
<string>fbapi20150629</string>
<string>fbapi20160328</string>
<string>fbauth</string>
<string>fbauth2</string>
<string>fb-messenger-api20140430</string>
</array>


如果使用版本低于 4.6 的 FBSDKMessengerShareKit,还要添加

<string>fb-messenger-platform-20150128</string>
<string>fb-messenger-platform-20150218</string>
<string>fb-messenger-platform-20150305</string>


如果使用 SDK v4.6.0 或更高版本,仅需添加:

<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>


这个操作的意思就是给跳转FB应用加白名单。更多信息参考官方文档

https://developers.facebook.com/docs/facebook-login/ios

-(void)loginButtonClicked
{
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login
logInWithReadPermissions: @[@"public_profile"]
fromViewController:self
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(@"Process error");
} else if (result.isCancelled) {
NSLog(@"Cancelled");
} else {
NSLog(@"Logged in");
}
}];
}


上面是第三方登录FB的回调

因为本人用的cocos2dx引擎,上述函数需要做成静态方法,然后用脚本去调此函数。

若是把此静态方法写在RootViewController.mm文件里,IOS9就会有一个运行报错.

解决办法是将上述self替换成实例化的对象。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: