iOS Google Plus API - Sharing or Logging In withou

2020-02-09 18:20发布

So far everything I've found on the subject, is a NO.

My app works fine when the user logs in and shares, but both actions require mobile safari, which is a less than ideal experience for the user, has anyone found a way to either share a post or log in to Google + using a UIWebView or GET/POST?.

Any help will be greatly appreciated.

Thanks.

3条回答
ら.Afraid
2楼-- · 2020-02-09 18:38

You can SignIn via Google+ into UIWebView.

 GTMOAuth2ViewControllerTouch *_googlePlusCtrl = [[GTMOAuth2ViewControllerTouch alloc]
                                                   initWithScope:@"https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.me"
                                                   clientID:GOOGLE_PLUS_CLIENT_ID
                                                   clientSecret:GOOGLE_PLUS_CLIENT_SECRET
                                                   keychainItemName:@"GooglePlus_Sample_App"
                                                   delegate:self
                          finishedSelector:@selector(viewController:finishedWithAuth:error:)];

Hope this will help you.

查看更多
放我归山
3楼-- · 2020-02-09 18:39

Easiest answer is no, as you say. The SDK will actually try to fall back through the following:

  1. Log in via Google+ app (this is the nice result, but requires having the Google+ app installed)
  2. Log in via Chrome
  3. Log in via Mobile Safari

You can control the first part with the attemptSSO flag on the GPPSignIn object - if you set that to NO it wont try to use the Google+ app. You'll generally want it to try the Google+ app first. Sharing always happens via the web (chrome/safari) with the current API version (1.2.1) though.

查看更多
家丑人穷心不美
4楼-- · 2020-02-09 18:50

Well that's the thing. It's possible. First step - download sample project from here - https://github.com/emysa341/Login-with-gmail-google-g--using-oath-2.0-protocol. Second step, in the response- connection did finish loading, make another request - https://www.googleapis.com/oauth2/v1/userinfo?access_token=%@ . Use the access token you got from the 1st request. Now in the response, you will get the user data. Also if you need the user's email, change the scope to "https://www.googleapis.com/auth/userinfo.email".

查看更多
登录 后发表回答