我想通过inApp从google+分享本机共享对话框,但正如文档中所述,它需要谷歌登录。但我不想提供一个单独的谷歌登录按钮为同样的。那么,是否可以转到safari进行google+登录(如果还没有登录),返回到app并在app中打开共享对话框?
另外,我需要知道google+ ios中的哪个函数处理静默身份验证,从而为我提供编写应用程序本机共享对话框代码的地方?
发布于 2015-01-12 11:20:50
找到了解决办法:
检查它是否已经登录。这是由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+登录,如果应用程序第一次没有批准。在批准该应用程序之后,它将使用委托方法重定向回app,在该方法中可以实现本机共享对话框:
- (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);
}https://stackoverflow.com/questions/27900354
复制相似问题