谷歌共享无需登录即可工作

Poo*_*hah 0 ios google-plus

我的共享代码如下:

id<GPPShareBuilder> shareBuilder = [[GPPShare sharedInstance] shareDialog];

// This line will fill out the title, description, and thumbnail from
// the URL that you are sharing and includes a link to that URL.

[shareBuilder setTitle:@"Try Sharing g+" description:@"demo" thumbnailURL:nil];

[shareBuilder open];
if (![shareBuilder open]) {
    NSLog(@"Status: error (see console)....");
}
Run Code Online (Sandbox Code Playgroud)

但我得到的错误如下:

由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'您必须指定| clientID | for | GPPSignIn |'

从谷歌开发者链接https://developers.google.com/+/mobile/ios/share/basic-share它说我可以分享而无需登录谷歌+,仍然无法正常工作.请提出一些解决方案.

Ste*_*eve 5

无论您是否希望用户登录,您都必须至少提前指定您的clientID:

GPPSignIn *signIn = [GPPSignIn sharedInstance]; 
signIn.clientID = kYourClientIDHere; 

id<GPPShareBuilder> shareBuilder = [[GPPShare sharedInstance] shareDialog];
[shareBuilder setURLToShare:[NSURL URLWithString:@"https://www.example.com/restaurant/sf/1234567/"]];
[shareBuilder open];
Run Code Online (Sandbox Code Playgroud)

您引用的示例代码/文档并没有明确说明 - 但它仍然是一个要求.

修复代码后,如果检查在浏览器中打开的URL,您将看到它包含您的ClientID.