我正在使用Xcode 8.0,在iOS 10.0上进行测试,并使用手动安装SDK,googlesignin/googlesignin.h。
成功登录应用程序崩溃后。我下面提到的eRROR消息
错误:
由于未被发现的例外,终止应用程序 " nsinvalidargumentException",原因: ' - [pinakinaudiolistviewController signin:didSignInforuser:witherror:]: 未识别的选择器发送到实例0x7fc44e863c00' ***第一次掷出电话堆栈:( 0 CoreFoundation 0x000000010229034b exceptionpreprocess 171 1 libobjc.a.dylib
0x00000001010596121E objc_exception_throw 48 2 CoreFoundation
0x00000001022FFF34- [NSObject(nsObject)do notRecognizesElector:] 132 3 Corefoundation 0x0000000102215A2E ___转发_ 526 4 CoreFoundation 0x0000000102215798 _cf_forwarding_prep_0 120 5 Pinakin
0x0000000100E517AF 37- [gidsignin addCalldelegateCallback:] _ block_invoke 116 6 pinakin
0x0000000100E49981- [Gidcallbackqueue Fire] 147 7 Pinakin
0x0000000100EE5735B- [Gidtokenfetchdelegate didfinishtokenfetchwithauth:fetcher:错误:] 53 8 CoreFoundation
0x000000010221705C __ INVOKING _ 140 9 CoreFoundation
0x0000000102216EE1- [NSINEVOCATION INDOKE] 289 10 PINAKIN
0x0000000100EE5C771 [gtmoauth2authentication Invokedelegate:选择器:对象:对象:对象:] 207 11 Pinakin
0x0000000100EE5BA79- [GTMOAUTH2AUTHENTICATY tokenfetcher:dearthwithdata:错误:] 648 12核心文件
0x000000010221705C 调用_ 140 13 CoreFoundation
0x0000000102216EE1- [NSINEVOCATION] 289 14 PINAKIN
0x0000000100E61BD3 67- [gtmsessionfetcher 完整handlerwithtarget:didfinishSelector:] _ block_invoke 268 15 Pinakin 0x0000000100E692C5 __71- [gtmsessionfetcher InvokefetchCallbacksonCallbacksequeuewithData:错误:] _ block_invoke 25 16 libdispatch.dylib 0x00000001064ff980 _dispatch_call_block_and_release 12 17 libdispatch.dylib 0x00000000001065290CD _dispatch_client_callout_callout 8 18 libdispatch.dylib 0x0000000106509a1d _dispatch_main_queue_callback_4cf 733 19 核心正面0x00000001022544f9 __cfrunloop_is_servicing_the_main_dispatch_queue 9 20 CoreFoundation 0x0000000000102219f8d __cfrunlooprun 2205 21 CoreFoundation 0x0000000102219494 CFRUNOPRUNSPEFIFIC 420 22 GraphicsServices
0x00000001081C2A6F GSEVENTRUNMODAL 161 23 UIKIT
0x0000000103449F34 UIAPPLICATIONMAIN 159 24 PINAKIN
0x0000000100DAA00F主 111 25 libdyld.dylib
0x00000001010657568D开始 1 26 ???
0x0000000000000001 0x0 1)libc abi.dylib:终止 未接收的nsexception
我使用此代码创建了自定义登录
GIDSignIn *sigNIn=[GIDSignIn sharedInstance];
[sigNIn setDelegate:self];
[sigNIn setUiDelegate:self];
sigNIn.shouldFetchBasicProfile = YES;
sigNIn.scopes = @[@"https://www.googleapis.com/auth/userinfo.email",@"https://www.googleapis.com/auth/userinfo.profile"];
sigNIn.clientID =@"851647387203-6n9vm1jpn8uv2c0g1qsrdi4nn69f8rh5.apps.googleusercontent.com";
[sigNIn signIn];
在AppDelegate
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
BOOL wasHandled=false;
if ([url.scheme hasPrefix:@"fb"]) {
wasHandled = [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation
];
//Facebook callback
}
else //Google Plus callback
{
wasHandled= [[GIDSignIn sharedInstance] handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
NSLog ( @"application openURL");
NSLog ( @"URL = %@", url);
NSLog ( @"Application = %@", sourceApplication);
return wasHandled;
}
只需在您的pinakinAudioListViewController
中实现委托GIDSignInDelegate
的signIn:didSignInForUser:withError:
方法。
- (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error {
NSLog(@"User signed in!");
}
请不要忘记也实现signIn:didDisconnectWithUser:withError:
。
另请参见:https://develoverers.google.com/indesity/sign-in/oios/api/protocol_g_i_d_sign_in_in_in_delegate-p
向您的ViewController实现GidSignIndelegate方法:
- (void)signInWillDispatch:(GIDSignIn *)signIn error:(NSError *)error
{
[SVProgressHUD dismiss];
}
- (void)signIn:(GIDSignIn *)signIn presentViewController:(UIViewController *)viewController
{
[self presentViewController:viewController animated:YES completion:nil];
}
- (void)signIn:(GIDSignIn *)signIn dismissViewController:(UIViewController *)viewController
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error
{
NSLog(@"%@",user);
}
您也可以将此方法写入您的AppDelegate类:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
return ([[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation]) || ([[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation]);
}
希望这对您有帮助。