用户必须login才能使用本地共享框

我想在我的应用程序中添加谷歌加上财产的份额。 我在谷歌的Web控制台注册客户端应用程序,并获得客户端ID。

在我的viewDidLoad函数中:

- (void)viewDidLoad{ CGRect rect = self.view.bounds; rect.size.height = rect.size.height - 50; _postContentUIWV = [[UIWebView alloc] initWithFrame:rect]; [_postContentUIWV loadHTMLString:selectedPostCD.content baseURL:nil]; [self.view addSubview:_postContentUIWV]; self.navigationController.navigationBar.tintColor = [UIColor whiteColor]; GPPSignIn *signIn = [GPPSignIn sharedInstance]; signIn.shouldFetchGooglePlusUser = YES; // signIn.shouldFetchGoogleUserEmail = YES; // Uncomment to get the user's email // You previously set kClientId in the "Initialize the Google+ client" step signIn.clientID = kClientID; [GPPSignIn sharedInstance].actions = [NSArray arrayWithObjects: @"http://schemas.google.com/AddActivity", @"http://schemas.google.com/BuyActivity", @"http://schemas.google.com/CheckInActivity", @"http://schemas.google.com/CommentActivity", @"http://schemas.google.com/CreateActivity", @"http://schemas.google.com/ListenActivity", @"http://schemas.google.com/ReserveActivity", @"http://schemas.google.com/ReviewActivity", nil]; // Uncomment one of these two statements for the scope you chose in the previous step signIn.scopes = @[ kGTLAuthScopePlusLogin ]; // "https://www.googleapis.com/auth/plus.login" scope //signIn.scopes = @[ @"profile" ]; // "profile" scope // Optional: declare signIn.actions, see "app activities" signIn.delegate = self; [signIn trySilentAuthentication]; } 

然后在我的onButtonCLick函数中:

 - (void) googlePlusShareTapped { id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog]; [shareBuilder setURLToShare:[NSURL URLWithString:@"https://www.shinnxstudios.com"]]; [shareBuilder setPrefillText:@"This is an awesome G+ Sample to share"]; // [shareBuilder setTitle:@"Title" description:@"Descp" thumbnailURL:[NSURL URLWithString:@"https://www.fbo.com/imageurl"]]; [shareBuilder open]; } 

但是我得到的消息:

  [lvl=3] -[GPPNativeShareBuilderImpl open] User must be signed in to use the native share box. 

我从App Store下载了Google +应用程序并login。但每次收到此消息,无法在Google +上共享任何内容。

有什么build议么?

首先从模拟器中删除你的应用程序,然后closuresXCode并重新打开并重新运行你的应用程序,通过更改以下代码:

 GPPSignIn *signIn = [GPPSignIn sharedInstance]; signIn.shouldFetchGooglePlusUser = YES; signIn.clientID = kClientId; signIn.scopes = @[ kGTLAuthScopePlusLogin ]; signIn.delegate = self; [signIn authenticate]; 

还要确保你必须将GooglePlus.bundle添加到你的应用程序中。