gpt4 book ai didi

ios - Google Plus 共享崩溃

转载 作者:可可西里 更新时间:2023-11-01 06:14:56 25 4
gpt4 key购买 nike

我使用的是 Google plus 最新框架 (google-plus-ios-sdk-1.7.0)。在 Google+ 分享上崩溃。执行方法 shareGooglePlusWithMessage 后,应用程序崩溃并在控制台上显示以下消息。请帮助我

- (void) loginGooglePlusWithClientId:(NSString*) clientId
{
clientId = kGooglePlus_CLientId;
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.clientID = clientId;
signIn.shouldFetchGooglePlusUser = YES;
signIn.shouldFetchGoogleUserEmail = YES;
signIn.shouldFetchGoogleUserID = YES;
[GPPSignIn sharedInstance].s`enter code here`copes = [NSArray arrayWithObjects:kGTLAuthScopePlusLogin,kGTLAuthScopePlusMe,nil];
signIn.delegate = self;
[signIn authenticate];
}

- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth error: (NSError *) error
{
NSLog(@"G+ User Id : %@", [NSString stringWithFormat:@"%@", [GPPSignIn sharedInstance].userID]);
NSLog(@"Received error %@ and auth object %@",error, auth);
if(auth && !error)
{
[self shareGooglePlusWithMessage:@"" andLink:@""];
}
}

- (void) shareGooglePlusWithMessage:(NSString*) msg andLink:(NSString*) urlStr
{
urlStr = @"https://www.techaheadcorp.com";
msg = @"Test Message";

id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
if(urlStr)
[shareBuilder setURLToShare:[NSURL URLWithString:urlStr]];
if(msg)
[shareBuilder setPrefillText:msg];

if(urlStr || msg)
[shareBuilder open];
}

- (void)finishedSharingWithError:(NSError *)error
{
if(error == nil)
NSLog(@"Success G+ Sharing");
//else
//NSLog(@"Failed G+ Sharing with error : %@", [error description]);
}

- (void)finishedSharing:(BOOL)shared
{

}
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]'*** First throw call stack:(    0   CoreFoundation                      0x041b81e4 __exceptionPreprocess + 180    1   libobjc.A.dylib                     0x03ab68e5 objc_exception_throw + 44    2   CoreFoundation                      0x0417e376 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 390    3   CoreFoundation                      0x041abc29 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 73    4   PineWallet                          0x003d7384 -[GPPOzLogger flushEventsAndBuildQuery] + 667    5   PineWallet                          0x003a394d -[GPPServiceBase executeQuery:usingService:batchLogsFrom:completionHandler:] + 868    6   PineWallet                          0x003da0bb -[GPPService executeQuery:usingService:batchLogsFrom:completionHandler:] + 657    7   PineWallet                          0x003da4a0 __72-[GPPService executeQuery:usingService:batchLogsFrom:completionHandler:]_block_invoke + 157    8   PineWallet                          0x003da76f __72-[GPPService executeQuery:usingService:batchLogsFrom:completionHandler:]_block_invoke109 + 490    9   PineWallet                          0x003a4424 __76-[GPPServiceBase executeQuery:usingService:batchLogsFrom:completionHandler:]_block_invoke + 1984    10  PineWallet                          0x00366e45 -[GTLService handleParsedObjectForFetcher:] + 1694    11  libobjc.A.dylib                     0x03ac882b -[NSObject performSelector:withObject:] + 70    12  Foundation                          0x0370ae48 __NSThreadPerformPerform + 285    13  CoreFoundation                      0x0414177f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15    14  CoreFoundation                      0x0414110b __CFRunLoopDoSources0 + 235    15  CoreFoundation                      0x0415e1ae __CFRunLoopRun + 910    16  CoreFoundation                      0x0415d9d3 CFRunLoopRunSpecific + 467    17  CoreFoundation                      0x0415d7eb CFRunLoopRunInMode + 123    18  GraphicsServices                    0x0503c5ee GSEventRunModal + 192    19  GraphicsServices                    0x0503c42b GSEventRun + 104    20  UIKit                               0x02776f9b UIApplicationMain + 1225    21  PineWallet                          0x0000294d main + 141    22  libdyld.dylib                       0x04a69701 start + 1    23  ???                                 0x00000001 0x0 + 1)libc++abi.dylib: terminating with uncaught exception of type NSException

最佳答案

对于初学者,我会逐行逐个断点查看您尝试插入 nil 对象的位置。

作为引用,我将把我的 Google+ 分享代码放在这里:

-(void)shareOnGooglePlus
{
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.shouldFetchGooglePlusUser = YES;
signIn.clientID = kClientId;
signIn.scopes = @[ kGTLAuthScopePlusLogin ];
signIn.delegate = self;
[signIn authenticate];
}

- (BOOL)application: (UIApplication *)application openURL: (NSURL *)url sourceApplication: (NSString *)sourceApplication annotation: (id)annotation
{
return [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation];
}

- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error
{
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];

NSString *shortDescription = [self.objectToShare valueForKey:@"descriptionShort"];
NSString *shareText = @"";
if (shortDescription.length > 0)
{
shareText = [NSString stringWithFormat:LOCALIZEDSTRING(@"share_text_default"), [self.objectToShare valueForKey:@"name"], [self.objectToShare valueForKey:@"descriptionShort"]];
}
else
{
shareText = [NSString stringWithFormat:LOCALIZEDSTRING(@"share_text_no_short"), [self.objectToShare valueForKey:@"name"]];
}

NSURL *shareUrl = [NSURL URLWithString:ITUNES_URL];

[shareBuilder setURLToShare:shareUrl];
[shareBuilder setPrefillText:shareText];

[shareBuilder open];
}

此外,请务必设置有效的 URL 类型(项目 -> 目标 -> 信息 -> URL 类型)

URLTYPE

关于ios - Google Plus 共享崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25401714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com