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
Jonah starling
source share