Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
549 views
in Technique[技术] by (71.8m points)

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

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"
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...