If your app has been using Google+ login for years, and suddenly the recent update got rejected with message like this:
Specifically, the app opens a web page in mobile Safari for Google+ authentication, then returns the user to the app. The user should be able to sign in to Google+ without opening Safari.
It’s time to upgrade google sign-in SDK, here is the online guide: https://developers.google.com/identity/sign-in/ios/start
Unfortunately, there are some confusion in that guide, hope the following tips can help you:
Steps
- Download Google Sign-in SDK (2.2.0 as is now), add GoogleSignIn.bundle and GoogleSignIn.framework to project. I am using manually instead of coacapods. (Recently pod caused enough problems to my other projects.)
- Get a Google Sign-In configuration file, from which you will find client-id, revised client-id which are needed later. This file itself is not in use.
- Add 2 more entry to project target info.plist file, I left facebook setup here so we can compare
<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLSchemes</key> <array> <string>fb425980604155625</string> </array> </dict> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLName</key> <string>com.foodplannerapp</string> <key>CFBundleURLSchemes</key> <array> <string>com.foodplannerapp</string> </array> </dict> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLSchemes</key> <array> <string>com.googleusercontent.apps.1070812041215-ap9sle5s7qnaqgeov8emb2r28simo39c</string> </array> </dict> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLSchemes</key> <array> <string>com.foodplannerapp</string> </array> </dict> </array>
- Code implementation, following online guide: https://developers.google.com/identity/sign-in/ios/sign-in
Note: You might encounter 2 difficulties here:a) Can’t add GIDSignInButton,
Workaround: create your own IBAction method:- (IBAction)signInWithGooglePlus:(id)sender { [[GIDSignIn sharedInstance] signIn]; }
b) Runtime Error:
When |allowsSignInWithWebView| is enabled, uiDelegate must either be a |UIViewController| or implement the |signIn:presentViewController:| and |signIn:dismissViewController:| methods from |GIDSignInUIDelegate|Solution: assign uiDelegate.
[GIDSignIn sharedInstance].clientID = kClientID; [GIDSignIn sharedInstance].delegate = self; [GIDSignIn sharedInstance].uiDelegate = self; //the following line is optional, default value is YES anyway [GIDSignIn sharedInstance].allowsSignInWithWebView = YES;
Observation: application:openURL: method is not called, as described as step 3 in doc: https://developers.google.com/identity/sign-in/ios/sign-in
The main purpose of using new SDK is to remove flipping between Safari, but if you do what to use flipping Safari to login google+, set allowsSignInWithWebView to NO, wala! you are back to old times, and get ready to see your app being rejected by Apple.