카카오 프사 없을 때 간편로그인 튕김 현상 문제

간편로그인을 시도하는데 카카오톡 프로필 이미지가 있을 경우에는 정상적으로 데이터를 콜백 받는데,
카카오톡 이미지를 등록하지 않은 사람은 프로필 이미지 데이터가 null로 확인이 되면서 앱이 튕깁니다.

어떻게 해결해야 하나요.

로그입니다.
2018-05-10 10:47:49.942115+0900 움직임[23786:2851840] profileImage=(null)
2018-05-10 10:47:49.942889+0900 움직임[23786:2851840] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]’
*** First throw call stack:
(0x181eeed8c 0x1810a85ec 0x181e87750 0x181dc00cc 0x181dbff48 0x100ae598c 0x100b1a3c8 0x100b0ff90 0x18247dc1c 0x18249693c 0x182916e88 0x1828588d0 0x182857cac 0x100c9d220 0x100ca9850 0x100c9d220 0x100ca9850 0x100ca9734 0x182918750 0x100c9d220 0x100ca1db0 0x181e97070 0x181e94bc8 0x181db4da8 0x183d97020 0x18bd9578c 0x100a713e8 0x181845fc0)
libc++abi.dylib: terminating with uncaught exception of type NSException

@dancefarm
어떤 메소드 호출할 때인가요?

@implementation KakaoTalk

  • (void) login:(CDVInvokedUrlCommand*) command
    {
    [[KOSession sharedSession] close];

    [[KOSession sharedSession] openWithCompletionHandler:^(NSError *error) {

      if ([[KOSession sharedSession] isOpen]) {
          // login success
          NSLog(@"login succeeded.");
          [KOSessionTask meTaskWithCompletionHandler:^(KOUser* result, NSError *error) {
              CDVPluginResult* pluginResult = nil;
      	    if (result) {
      	        // success
      	        NSLog(@"userId=%@", result.ID);
      	        NSLog(@"nickName=%@", [result propertyForKey:@"nickname"]);
                  NSLog(@"profileImage=%@", [result propertyForKey:@"profile_image"]);
      	        
      	        NSDictionary *userSession = @{
      								  @"id": result.ID,
      								  @"nickname": [result propertyForKey:@"nickname"],
      								  @"profile_image": [result propertyForKey:@"profile_image"]};
      			pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:userSession];
      	    } else {
      	        // failed
      	        NSLog(@"login session failed.");
      	        pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]];
      	    }
              [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
      	}];
      } else {
          // failed
          NSLog(@"login failed.");
          CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]];
          [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
      }
    

    }];
    }

@“profile_image”: [result propertyForKey:@“profile_image”]}; 이 부분에서 카톡 프사가 없는 경우에는 null로 들어오는데 이때 저 위에 제가 말한 에러 로그이며, 튕깁니다. 그러나 카톡 프사가 있는 경우에는 값이 null로 들어오지 않아서 정상적으로 카카오 로그인 API가 실행됩니다.

@dancefarm
저희 메소드 내부 동작이 아니네요ㅠ

NSDictionary *userSession = @{ ...
                              @"profile_image": [result propertyForKey:@"profile_image"]};

위 코드가 크래시를 내는 부분인데
Objective-C 프로그래밍에서 @{ key : value } 형식의 Dictionary 리터럴은 value가 nil일 때 해당 크래시가 발생합니다.

감사합니다.