Sign in to your iOS iOS account

I use Google login for my iOS application. I followed a Google tutorial ( https://developers.google.com/identity/sign-in/ios/sign-in#add_the_sign-in_button ) that uses the GIDSignInButton, which the user needs to click. When he clicks on it, it redirects to Safari, which looks like this:

enter image description here

The problem is that I have several Google accounts and I would like to choose which one I want to use. Now it just takes one of them automatically, and all I have to do is click "deny" or "allow". Also, I don't like the fact that the app is being redirected to Chrome. Ideally, what I would like is something like the Google Hangouts app on iOS:

enter image description here

It shows you all the accounts that you previously logged into any Google application, and allows you to decide which ones to use with the application without leaving the application. On Android, I have something similar for my application:

enter image description here

How can I achieve this behavior (don't leave app + account chooser) in my iOS app?

+7
android ios login
source share
1 answer

The reason they can do this on Google Hangouts is because it did Google. Companies do not always make every feature available to developers, and this is a prime example. The reason you were able to do this on Android was because Google decided to allow developers more access to various functions. After all, Android is developed by Google. Now, in order not to leave the application, you can always use the built-in web view. This will force the user to log into the application and display the web view instead. This is not the best in the world, but better than the user sent somewhere else. Have you tried this code:

// Implement these methods only if the GIDSignInUIDelegate is not a subclass of // UIViewController. // Stop the UIActivityIndicatorView animation that was started when the user // pressed the Sign In button func signInWillDispatch(signIn: GIDSignIn!, error: NSError!) { myActivityIndicator.stopAnimating() } // Present a view that prompts the user to sign in with Google func signIn(signIn: GIDSignIn!, presentViewController viewController: UIViewController!) { self.presentViewController(viewController, animated: true, completion: nil) } // Dismiss the "Sign in with Google" view func signIn(signIn: GIDSignIn!, dismissViewController viewController: UIViewController!) { self.dismissViewControllerAnimated(true, completion: nil) } 

I found this on the link you posted. I haven't run or tested the code, but it seems to represent a view controller instead of sending you a safari. It may be more according to what you want.

To answer @Sam's question:

"How do I log in to Google through existing Google applications that are installed, rather than opening a URL in Safari?"

Perhaps you can accomplish this using Android, but not iOS. This is another example of what is limited due to the chosen platform.

Remember, no matter which option you choose, you still have to stick with OAuth 2.0. I would suggest, if at all possible, to use what Google has built for iOS developers. When you choose a different account than the standard one, if you decide to follow the guide and do what Google created for iOS developers, you can simply click on the profile picture and switch accounts.

TL; DR

https://www.youtube.com/watch?time_continue=227&v=-26DGO_E1ds

+3
source share

All Articles