linto jacob linto jacob -4 years ago 155
iOS Question

After successfully Google login App is crashing in IOS(Objective C)

I am using Xcode 8.0, testing on iOS 10.0 and using manually installed the SDK, GoogleSignIn/GoogleSignIn.h.

After successfully login App is crashing.Error message i mentioned below

Error:-

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[pinakinAudioListViewController signIn:didSignInForUser:withError:]: unrecognized selector sent to instance 0x7fc44e863c00'
*** First throw call stack:
(
0 CoreFoundation 0x000000010229034b exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010596121e objc_exception_throw + 48
2 CoreFoundation 0x00000001022fff34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x0000000102215a2e ___forwarding_
+ 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 0x0000000100e5735b -[GIDTokenFetchDelegate didFinishTokenFetchWithAuth:fetcher:error:] + 53
8 CoreFoundation 0x000000010221705c __invoking_
+ 140
9 CoreFoundation 0x0000000102216ee1 -[NSInvocation invoke] + 289
10 Pinakin 0x0000000100e5c771 +[GTMOAuth2Authentication invokeDelegate:selector:object:object:object:] + 207
11 Pinakin 0x0000000100e5ba79 -[GTMOAuth2Authentication tokenFetcher:finishedWithData:error:] + 648
12 CoreFoundation 0x000000010221705c invoking_ + 140
13 CoreFoundation 0x0000000102216ee1 -[NSInvocation invoke] + 289
14 Pinakin 0x0000000100e61bd3 67-[GTMSessionFetcher completionHandlerWithTarget:didFinishSelector:]_block_invoke + 268
15 Pinakin 0x0000000100e692c5 __71-[GTMSessionFetcher invokeFetchCallbacksOnCallbackQueueWithData:error:]_block_invoke + 25
16 libdispatch.dylib 0x00000001064ff980 _dispatch_call_block_and_release + 12
17 libdispatch.dylib 0x00000001065290cd _dispatch_client_callout + 8
18 libdispatch.dylib 0x0000000106509a1d _dispatch_main_queue_callback_4CF + 733
19 CoreFoundation 0x00000001022544f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE
+ 9
20 CoreFoundation 0x0000000102219f8d __CFRunLoopRun + 2205
21 CoreFoundation 0x0000000102219494 CFRunLoopRunSpecific + 420
22 GraphicsServices 0x00000001081c2a6f GSEventRunModal + 161
23 UIKit 0x0000000103449f34 UIApplicationMain + 159
24 Pinakin 0x0000000100daa00f main + 111
25 libdyld.dylib 0x000000010657568d start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

And i created custom login using this code

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];


In 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;


}

Answer Source

Simply implement the signIn:didSignInForUser:withError: method of delegate GIDSignInDelegate in your pinakinAudioListViewController.

- (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error {
  NSLog(@"User signed in!");
}

Please do not forget to implement the signIn:didDisconnectWithUser:withError: as well.

Also see: https://developers.google.com/identity/sign-in/ios/api/protocol_g_i_d_sign_in_delegate-p

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download