11

我已经实现了Google Plus Api并按照网站中给出的方式登录。但是当我点击允许访问时,登录后出现问题,如下所示:

在此处输入图像描述

出现以下消息:

在此处输入图像描述

我的代码如下,如果还有什么,请告诉我:

    - (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;
}
4

1 回答 1

44

您必须在您的项目中使用您的捆绑 ID 分配重定向 uri,因此在成功验证后,如果您正确处理您的 url,您的应用程序将从 safari 启动:

在此处输入图像描述

将包 ID 作为标识符和 URLSchemes...

于 2012-12-26T08:48:39.560 回答