我已经为 ios 集成了 Google Plus SDK 并设置了所有内容以供共享。但是在打开共享显示弹出窗口然后用户共享或取消共享之后是否有回调。我想知道它所说的委托(delegate)方法。
我知道 -(void)finishedSharingWithError:(NSError *)error
是委托(delegate)方法,但它没有被调用。
这是我通过 google plus 分享的代码..
-(void)postToGooglePlus:(PostModel *)parameter{
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.shouldFetchGooglePlusUser = YES;
signIn.clientID = kClientId;
signIn.scopes = @[ kGTLAuthScopePlusLogin ];
signIn.delegate = self;
[signIn authenticate];
}
- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
error: (NSError *) error {
NSLog(@"Received error %@ and auth object %@",error, auth);
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
[shareBuilder setPrefillText:@"This is a test"];
[shareBuilder open];
}
-(void)finishedSharingWithError:(NSError *)error{
if(!error){
}
}
最佳答案
您必须设置 <GPPShareDelegate>
首先到你的 View Controller 。在那之后设置 delegate
在你的 - (void)finishedWithAuth: (GTMOAuth2Authentication *)auth error: (NSError *) error
中这样方法:
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
[GPPShare sharedInstance].delegate = self;
您现在可以调用 -(void)finishedSharingWithError:(NSError *)error
或 -(void)finishedSharing:(BOOL)shared
相应地。
关于ios - Google Plus SDK 回调分享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32604714/