Google Sign-In Crashes on iOS 9 Attempting to Call Canopenurl

Google Sign-In crashes on iOS 9 attempting to call canOpenURL

iOS 9 has introduced new changes to canOpenURL requiring the application to whitelist all the schemes it needs to query.

This post on Quick Take on iOS 9 URL Scheme Changes explains why.

At a minimum you need to whitelist you own application’s identifier and your Google OAuth apps id in Info.plist under LSApplicationQueriesSchemes. You can also whitelist the other schemes Google Sign-In queries to silence the other warnings.

LSApplicationQueriesSchemes

com.example.foo
com.googleusercontent.apps.1234567890-abcdefghijklmnopqrstuvwxyz
com-google-gidconsent-google
com-google-gidconsent-youtube
com-google-gidconsent
com.google.gppconsent.2.4.1
com.google.gppconsent.2.4.0
googlechrome
googlechrome-x-callback

Google+ Sign-In vs Google Sign-In Libraries [iOS 9 canOpenURL error]

Well, at the time of this writing, there's a big "This library has been deprecated" warning on the Google+ library documentation page, so I guess my recommendation at this point would be to go with the Google Sign-in one.

iOS 9.3 freeze after calling openURL

This indeed causes a deadlock when being called on the main thread on iOS 9.3 (tested on an iPhone 6 and iPhone 6 Plus).

semaphore

Backtrace:

* thread #1: tid = 0x41840, 0x0000000180ac1014 libsystem_kernel.dylib`semaphore_wait_trap + 8, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
* frame #0: 0x0000000180ac1014 libsystem_kernel.dylib`semaphore_wait_trap + 8
frame #1: 0x000000010023fa20 libdispatch.dylib`_dispatch_semaphore_wait_slow + 244
frame #2: 0x0000000180bda934 libxpc.dylib`xpc_connection_send_message_with_reply_sync + 204
frame #3: 0x000000018276a238 MobileCoreServices`_LSStartOpenOperation + 232
frame #4: 0x0000000182791efc MobileCoreServices`-[LSOpenOperation main] + 1160
frame #5: 0x0000000182771bc0 MobileCoreServices`-[LSApplicationWorkspace openURL:withOptions:error:] + 472
frame #6: 0x000000018633cdd8 UIKit`-[UIApplication _openURL:] + 356
frame #7: 0x0000000100096c04 MyApp`__29-[ViewController someMethod]_block_invoke(.block_descriptor=0x0000000125d37e20) + 216 at ViewController.m:57
frame #8: 0x000000010022da7c libdispatch.dylib`_dispatch_call_block_and_release + 24
frame #9: 0x000000010022da3c libdispatch.dylib`_dispatch_client_callout + 16
frame #10: 0x00000001002334e4 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 2096
frame #11: 0x0000000180ef8dd8 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
frame #12: 0x0000000180ef6c40 CoreFoundation`__CFRunLoopRun + 1628
frame #13: 0x0000000180e20d10 CoreFoundation`CFRunLoopRunSpecific + 384
frame #14: 0x0000000182708088 GraphicsServices`GSEventRunModal + 180
frame #15: 0x00000001860f5f70 UIKit`UIApplicationMain + 204
frame #16: 0x00000001000970d0 MyApp`main(argc=1, argv=0x000000016fd6fae8) + 124 at main.m:14
frame #17: 0x00000001809be8b8 libdyld.dylib`start + 4

I found that wrapping the entire call in a dispatch_async block fixed the issue:

dispatch_async(dispatch_get_main_queue(), ^{
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
});

I would file a Radar with Apple and post it on Open Radar.

Looks like this was fixed with iOS 9.3.1:

Fixes an issue that caused apps to be unresponsive after tapping on links in Safari and other apps.

google signin issue in ios9

I faced the same issue: google sign in via GIDSignIn works perfectly for

But for iOS9, Google.com page is opened once allow is pressed. If I press Done button on this page, control enters into aformentioned method, with error = Error Domain=com.google.GIDSignIn Code=-5 "The user canceled the sign-in flow." UserInfo={NSLocalizedDescription=The user canceled the sign-in flow.}

I researched a bit. Found two possible solution:

  1. Whitelist signin related urls- Google Sign-In crashes on iOS 9 attempting to call canOpenURL

  2. Use handleurl call-
    GIDSignIn iOS 9

Not getting time to test which suits best. Will update as soon as final solution is here.

Update: Did it!!

iOS9 has updated handleUrl() call. Streamlined two approaches as follows:

(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options NS_AVAILABLE_IOS(9_0)
{
return [self application:app
processOpenURLAction:url
sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
iosVersion:9];
}


(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [self application:application
processOpenURLAction:url
sourceApplication:sourceApplication
annotation:annotation
iosVersion:8];
}

(BOOL)application:(UIApplication *)application processOpenURLAction:(NSURL*)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation iosVersion:(int)version
{
return [[GIDSignIn sharedInstance] handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}


Related Topics



Leave a reply



Submit