繁体   English   中英

在应用程序本机共享对话框和iOS中的Google+登录中

[英]In app native share dialog and google+ signin in iOS

我想通过Google+的inApp本机共享对话框进行共享,但是如文档所述,它需要Google登录。但是我不想为此提供单独的Google登录按钮。 因此,是否可以前往safari进行google +登录(如果尚未登录),还原回应用程序并在应用程序中打开共享对话框?

另外,我需要知道google + ios sdk中的哪个函数可以处理静默身份验证,从而为我提供了编写应用程序本机共享对话框代码的地方?

找到了解决方案:

  1. 点击共享按钮时:

检查其是否已经登录。 这是由sdk处理的,但是需要这样做:

GPPSignIn *signIn = [GPPSignIn sharedInstance];
[signIn authenticate];

signIn.shouldFetchGooglePlusUser = YES;


signIn.scopes = @[ kGTLAuthScopePlusLogin ];  // "https://www.googleapis.com/auth/plus.login" scope

// Optional: declare signIn.actions, see "app activities"
signIn.delegate = self;

现在,如果应用未首次获得批准,我们将其重定向到safari google +登录。 批准该应用程序后,它将使用委托方法重定向回应用程序,在该方法中可以实现本机共享对话框:

- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
               error: (NSError *) error {
id<GPPShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];

// Set any prefilled text that you might want to suggest
[shareBuilder setPrefillText:@"Please visit http://abcd.in to view my listing"];

[shareBuilder setURLToShare:[NSURL URLWithString:@"http://abcd.in"]];

[shareBuilder open];
NSLog(@"Received error %@ and auth object %@",error, auth);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM