While testing Google Sign-In 2.1.0 on the iOS 9 SDK, invoking GIDSignIn.sharedInstance().signInSilently()
ends up crashing on an internal Google Sign-In SDK call to canOpenURL
.
-canOpenURL: failed for URL: "com.googleusercontent.apps.1234567890-abcdefghijklmnopqrstuvwxyz://a" - error: "This app is not allowed to query for scheme com.googleusercontent.apps.1234567890-abcdefghijklmnopqrstuvwxyz"
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Your app must support the following URL schemes: com.example.foo, com.googleusercontent.apps.1234567890-abcdefghijklmnopqrstuvwxyz'
-canOpenURL: failed for URL: "com-google-gidconsent-google://" - error: "This app is not allowed to query for scheme com-google-gidconsent-google"
-canOpenURL: failed for URL: "com-google-gidconsent-youtube://" - error: "This app is not allowed to query for scheme com-google-gidconsent-youtube"
-canOpenURL: failed for URL: "com-google-gidconsent://" - error: "This app is not allowed to query for scheme com-google-gidconsent"
-canOpenURL: failed for URL: "com.google.gppconsent.2.4.1://" - error: "This app is not allowed to query for scheme com.google.gppconsent.2.4.1"
-canOpenURL: failed for URL: "com.google.gppconsent.2.4.0://" - error: "This app is not allowed to query for scheme com.google.gppconsent.2.4.0"
-canOpenURL: failed for URL: "googlechrome:" - error: "This app is not allowed to query for scheme googlechrome"
-canOpenURL: failed for URL: "googlechrome-x-callback:" - error: "This app is not allowed to query for scheme googlechrome-x-callback"
-canOpenURL: failed for URL: "googlechrome-x-callback:" - error: "This app is not allowed to query for scheme googlechrome-x-callback"
-canOpenURL: failed for URL: "googlechrome:" - error: "This app is not allowed to query for scheme googlechrome"
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.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>com.example.foo</string>
<string>com.googleusercontent.apps.1234567890-abcdefghijklmnopqrstuvwxyz</string>
<string>com-google-gidconsent-google</string>
<string>com-google-gidconsent-youtube</string>
<string>com-google-gidconsent</string>
<string>com.google.gppconsent.2.4.1</string>
<string>com.google.gppconsent.2.4.0</string>
<string>googlechrome</string>
<string>googlechrome-x-callback</string>
</array>