Facebook登录iOS 10的问题 [英] Facebook login issue with iOS 10
问题描述
我用Facebook登录我的应用程序。
尝试使用Facebook登录 iOS 10
,iPhone模拟器6s。
-canOpenURL:URL失败:fbauth2:/ - 错误:操作无法完成(OSStatus错误-10814)
10814:kLSApplicationNotFoundErr
-10814启动服务数据库中的任何应用程序都不符合输入条件。
我正在使用Facebook sdk版本 4.13.1。
在XCode 8之前,相同的代码正常工作。
任何帮助?
提前感谢
错误状态 10814 基本上发生在 cantOpenUrl
,由 facebook
用于使用参数调用 url
fbauth2:/ 。由于建议bt这个
发布在这篇文章中的论坛开发者问题
问题出在 FBSDLoginManager ,完成处理程序从未被调用
所以在调试中,作者将断点放在 FBSDKLoginManager.m atlogInWithBehavior:(FBSDKLoginBehavior)loginBehavior和查找weakSelf无法调用logInWithBehavior:serverConfiguration: serverConfigurationLoadError:
- (void)logInWithBehavior:(FBSDKLoginBehavior)loginBehavior
{
__weak __typeof __(self)weakSelf = self ;
[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:^(FBSDKServerConfiguration * serverConfiguration,NSError * loadError){
[weakSelf logInWithBehavior:loginBehavior serverConfiguration:serverConfiguration serverConfigurationLoadError:loadError];
}];
}
解决方案1:
将FBSDKLoginManager 变量作为属性更改,而不是用作函数变量。确保
FBSDKLoginManager 变量必须保持活动,直到完成处理程序调用
您可以打开 -Wimplicit-retain-self 警告,以便在块中意外引用 self 时发出警告。 a href =https://github.com/facebook/KVOController/issues/82 =noreferrer> Github问题
解决方案2:
您可以将这些添加到您的plist
<密钥GT; NSAppTransportSecurity< /密钥GT;
< dict>
< key> NSExceptionDomains< / key>
< dict>
< key> akamaihd.net< / key>
< dict>
< key> NSIncludesSubdomains< / key>
< true />
< key> NSThirdPartyExceptionRequiresForwardSecrecy< / key>
< false />
< / dict>
< key> facebook.com< / key>
< dict>
< key> NSIncludesSubdomains< / key>
< true />
< key> NSThirdPartyExceptionRequiresForwardSecrecy< / key>
< false />
< / dict>
< key> fbcdn.net< / key>
< dict>
< key> NSIncludesSubdomains< / key>
< true />
< key> NSThirdPartyExceptionRequiresForwardSecrecy< / key>
< false />
< / dict>
< / dict>
< / dict>
< key> LSApplicationQueriesSchemes< / key>
< array>
< string> fbapi< / string>
< string> fb-messenger-api< / string>
< string> fbauth2< / string>
< string> fbshareextension< / string>
< / array>
,并更改 AppDelegate 如下
func应用程序(_应用程序:UIApplication,didFinishLaunchingWithOptions launchOptions:[UIApplicationLaunchOptionsKey:Any]?) - > Bool {
//在应用程序启动后重写自定义点。
返回SDKApplicationDelegate.shared.application(应用程序,didFinishLaunchingWithOptions:launchOptions)
}
func应用程序(_ app:UIApplication,打开url:URL,选项:[UIApplicationOpenURLOptionsKey:Any] = [:] ) - > Bool
{
return SDKApplicationDelegate.shared.application(app,open:url,options:options)
}
如作者所建议的
之后,您可以在 XCode8上运行您的 swift3,SDK,ios10
另请参阅作者,如果 Google Analytics(分析)将自己的控制器添加到设置
将embase -Info.plist 中的em>解决了这个问题。
>
完全归因于论坛和论坛提到的作者
I use facebook to login into my application.
Trying to login using Facebook on iOS 10
, iPhone simulator 6s.
-canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
10814 : kLSApplicationNotFoundErr
-10814 No application in the Launch Services database matches the input criteria.
I am using facebook sdk version 4.13.1. Before XCode 8, same code was working perfectly.
Any Help ? Thanks in advance.
Error status 10814 occurs basically when cantOpenUrl
,which is used by the facebook
to call the url
using the arguments fbauth2:/ .As suggested bt this thread,printing happens inside this function so you cant do anything much with that
Apple changed the way of working with IOS 10.To fix this issue you can go to
Targets > Capabilities > Enable Keychain
Sharing
Here is a screenshot from the same thread linked above
As posted in this post the of the forums developor issues
The problem is with the FBSDLoginManager , the completion handler is never called
so in debuging, the author put the breakpoint in "FBSDKLoginManager.m" at "logInWithBehavior: (FBSDKLoginBehavior)loginBehavior" and findout that weakSelf getting nil and not be able to call "logInWithBehavior: serverConfiguration: serverConfigurationLoadError:"
- (void)logInWithBehavior:(FBSDKLoginBehavior)loginBehavior
{
__weak __typeof__(self) weakSelf = self;
[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:^(FBSDKServerConfiguration *serverConfiguration, NSError *loadError) {
[weakSelf logInWithBehavior:loginBehavior serverConfiguration:serverConfiguration serverConfigurationLoadError:loadError];
}];
}
Solution 1:
Change FBSDKLoginManager variable as property rather than using as function variable. Make sure, FBSDKLoginManager variable must remain alive until the completion handler call
You can turn on the -Wimplicit-retain-self warning to get a warning if you reference self accidentally in a block.Posted in the Github issues
Solution 2:
You can add these to your plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
and also changing the AppDelegate as follows
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool
{
return SDKApplicationDelegate.shared.application(app, open: url, options: options)
}
as suggested by author After this you can run your swift3,SDK,ios10 on XCode8
Also check as mention by the author if the Google Analytics was adding its own controller on the top of your view controller by setting
Setting "FirebaseAppDelegateProxyEnabled" to "NO" in the -Info.plist solved the problem.
.
Full attribution goes to the forum and the authors mentioned in the forum
这篇关于Facebook登录iOS 10的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!