我已经成功实施了我的应用程序的iOS版Google登录版(Google + Twitter + Facebook版Android工作)。现在我正在尝试添加FB登录,但它似乎与谷歌的登录有冲突。在我看到WebView中成功的FB登录屏幕并按OK - 应用程序崩溃。
Error Domain=com.google.GIDSignIn Code=-4 "(null)"
2016-09-01 18:51:55.745 APP_NAME[4574:] <FIRAnalytics/INFO> Firebase Analytics enabled
2016-09-01 18:52:10.039 APP_NAME[4574:3352620] -canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"
2016-09-01 18:52:10.075 APP_NAME[4574:3352620] -canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"
(lldb) bt
* thread #1: tid = 0x33282c, 0x014dbd54 libswiftCore.dylib`swift::_swift_getClass(void const*), queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x014dbd54 libswiftCore.dylib`swift::_swift_getClass(void const*)
frame #1: 0x014d2e62 libswiftCore.dylib`swift_getObjectType + 8
frame #2: 0x0013dba0 APP_NAME`@objc AppDelegate.application(UIApplication, open : URL, sourceApplication : String?, annotation : Any) -> Bool + 328 at AppDelegate.swift:0
frame #3: 0x001e8046 APP_NAME`-[FIRAAppDelegateProxy application:openURL:sourceApplication:annotation:] + 150
frame #4: 0x258f214a UIKit`__45-[UIApplication _applicationOpenURL:payload:]_block_invoke + 906
frame #5: 0x258f1c1a UIKit`-[UIApplication _applicationOpenURL:payload:] + 546
frame #6: 0x258f9e8a UIKit`-[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:completion:] + 3658
frame #7: 0x258fe986 UIKit`__88-[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:]_block_invoke + 174
frame #8: 0x258fe898 UIKit`-[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:] + 396
frame #9: 0x258ea472 UIKit`__70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 134
frame #10: 0x258ea160 UIKit`-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 644
frame #11: 0x2271cc28 FrontBoardServices`__80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke_2 + 40
frame #12: 0x22737bf6 FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 18
frame #13: 0x22737aa6 FrontBoardServices`-[FBSSerialQueue _performNext] + 226
frame #14: 0x22737da4 FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 44
frame #15: 0x2102b9e6 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
frame #16: 0x2102b5d6 CoreFoundation`__CFRunLoopDoSources0 + 454
frame #17: 0x2102993e CoreFoundation`__CFRunLoopRun + 806
frame #18: 0x20f781c8 CoreFoundation`CFRunLoopRunSpecific + 516
frame #19: 0x20f77fbc CoreFoundation`CFRunLoopRunInMode + 108
frame #20: 0x22594af8 GraphicsServices`GSEventRunModal + 160
frame #21: 0x256b1434 UIKit`UIApplicationMain + 144
* frame #22: 0x001439a0 APP_NAME`main + 172 at AppDelegate.swift:12
frame #23: 0x20c24872 libdyld.dylib`start + 2
AppDelegate的代码
@available(iOS 9.0, *)
func application(_ application: UIApplication,
open url: URL, options: [String: Any]) -> Bool {
print(url)
print(options)
return GIDSignIn.sharedInstance().handle(url as URL!,
sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication.rawValue] as? String,
annotation: options[UIApplicationOpenURLOptionsKey.annotation.rawValue])
|| FBSDKApplicationDelegate.sharedInstance().application(application, open: url,
sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication.rawValue] as? String,
annotation: options[UIApplicationOpenURLOptionsKey.annotation.rawValue])
}
func application(_ application: UIApplication,
open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return GIDSignIn.sharedInstance().handle(url as URL!, sourceApplication: sourceApplication!, annotation: annotation)
|| FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
}
答案 0 :(得分:5)
这个问题是由Apple“创新”造成的。使用Xcode 8 beta 6,我必须使用
@available(iOS 9.0, *)
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {