Ios G+;sdk提供登录错误?
我已经实现和登录,因为它是在网站上给出的。但在登录后单击“允许访问”时出现问题,如下所示: 出现以下消息: 我的代码如下,如果还剩下什么,请告诉我:Ios G+;sdk提供登录错误?,ios,google-plus,Ios,Google Plus,我已经实现和登录,因为它是在网站上给出的。但在登录后单击“允许访问”时出现问题,如下所示: 出现以下消息: 我的代码如下,如果还剩下什么,请告诉我: - (void)viewDidLoad { self.signInButton.delegate = self; self.signInButton.clientID = kClientId; self.signInButton.scope = [NSArray arrayWithObjects:
- (void)viewDidLoad
{
self.signInButton.delegate = self;
self.signInButton.clientID = kClientId;
self.signInButton.scope = [NSArray arrayWithObjects:
@"https://www.googleapis.com/auth/plus.me",
nil];
SLNetworkAppDelegate *appDelegate = (SLNetworkAppDelegate*)
[[UIApplication sharedApplication] delegate];
appDelegate.signInButton = self.signInButton;
share =[[GPPShare alloc] initWithClientID:kClientId];
share.delegate = self; // optional
appDelegate.share=share;
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction) didTapShare: (id)sender {
[[[[share shareDialog]
setURLToShare:[NSURL URLWithString:@"https://developers.google.com/+/mobile/ios/getting-started"]]
setPrefillText:@"testing share via google plus"] open];
// Or, without a URL or prefill text:
[[share shareDialog] open];
}
In App delegate file:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if ([signInButton handleURL:url
sourceApplication:sourceApplication
annotation:annotation]) {
return YES;
}
if ([self.share handleURL:url
sourceApplication:sourceApplication
annotation:annotation]) {
return YES;
}
return NO;
}
您必须在项目中使用您的bundle ID分配重定向uri,如下所示,以便在成功验证后,如果您正确处理url,您的应用程序将从safari启动:
将bundle Id作为标识符,URLSchemes…可能是您在google plus中指定的重定向url不匹配。检查google plus客户端应用程序中的重定向url,确保在应用程序plist filehello@Sumanth中分配相同的url处理,我没有指定重定向url,请告诉我可以在哪里指定。您已经在google中创建了一个应用程序,因此您在那里获得了kClientId。您需要指定重定向url,以便在验证后,safari浏览器将处理url并打开您的应用程序。我对设置iOS应用程序的捆绑id有疑问。我的bundle id只是项目名称,它没有任何像'com.companyname'这样的前缀。所以它说“redirect_uri的参数值无效:缺少权限:”。是否有必要在bundle id中添加前缀。谢谢,我刚刚将bundle id设置为URLSchemes,工作正常