Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Sign-In is not returning to my app

I have a problem with Google Sign-in not redirecting back to my app.

I have followed the steps (https://developers.google.com/identity/sign-in/ios/start-integrating), installed cocoapods, downloaded the GoogleService-Info.plist (added it to all of my targets), added the URL Types (my bundle identifier and then my reverse client ID to my target and followed the steps line by line.

Here is the source code of the plist CFBundleURLTypes:

    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>MY_REVERSE_CLIENT_ID</string>
        </array>
        <key>CFBundleURLName</key>
        <string>MY_BUNDLE_ID</string>
    </dict>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>MY_BUNDLE_ID</string>
        </array>
        <key>CFBundleURLName</key>
        <string>MY_BUNDLE_ID</string>
    </dict>

In the App Delegate, I configured the [GGLContext sharedInstance] and in application openURL method I added-

return [[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation];

If the Google Plus app is not installed, then safari opens in app just fine and once signed in, the delegate callback methods work just as expected.

I believe this is an issue with iOS9. This worked before on iOS8.

I have also added com-google-gidconsent and com-google-gidconsent-google to LSApplicationQueriesSchemes in my plist, as I saw another post that said that could be the issue.

I have checked that in the google developer portal my bundle ID matches my project's bundle id as well as the client id and reverse client id are correct.

I have three targets (production, staging and testing). I am currently just trying to get the production target working.

I have another view controller where a user clicks a google button and then the action for that button is [[GIDSignIn sharedInstance] signIn]; This takes the user to the Google Plus App and prompts the user to select an account. Once an account is selected, the google plus app then asks the user if my app can access their information. Once a user clicks OK, there is no callback to my app. The user is simply stuck in the Google Plus App. I have a breakpoint in the application openURL method and it never gets hit.

Interestingly enough, if I configure my plist with com-google-gidconsent-google and com.google.gidconsent in the URL schemes with my reverse client id, the application openURL method gets hit but the

[[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation];

evaluates to NO.

Any help would be greatly appreciated.

like image 223
BEM319 Avatar asked Oct 19 '22 01:10

BEM319


1 Answers

Check your application:openURL:sourceApplication:annotation: method, or application:openURL:options: (depends of which one you have in your AppDelegate). Should be something like this implemented for google url scheme

return [[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation];
like image 174
Volodymyr Smolianinov Avatar answered Oct 21 '22 16:10

Volodymyr Smolianinov