5. Integrate IOS client

This page explains how to use the iES SDK.
Click the iES iOS Sample Download button in the Downloading the Sample Code page to download the sample code.

SDK initialization

Copy the Project folder > iES_Lib.framework file.
Add iES_Lib.framework in Project > TARGETS > Build Phases > Link Binary With Libraries.

PUSH reception registration

  • To use the iES service, push reception must be enabled.
    The example code below is used to enable push reception.
#import <PASSIPAD_Lib/PASSIPADManager.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    ..
    ..
    //푸쉬 알림 등록 필수 
    if ([application respondsToSelector:@selector(registerUserNotificationSettings:)])
    {
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound |
                                                                                             UIUserNotificationTypeAlert)
                                                                                 categories:nil];
        [application registerUserNotificationSettings:settings];
        [application registerForRemoteNotifications];
    }
    else
    {
        UIRemoteNotificationType myTypes = UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
        [application registerForRemoteNotificationTypes:myTypes];
    }
    
    // 이전 파트너사 등록이 되어 있는 경우 설정
    NSString *partnerCode = [[PASSIPADManager shared] getPartnerCode];
    if(partnerCode != nil)
        [[PASSIPADManager shared] setWithAppType:[NSString stringWithFormat:@"%@",partnerCode]];
  
    return YES;
}

Callback to be called when the device is successfully registered to the APNS

//APNS에 장치 등록 성공시 호출되는 콜백
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    NSMutableString *deviceId = [NSMutableString string];
    const unsigned char* ptr = (const unsigned char*) [deviceToken bytes];
    
    for(NSInteger i = 0 ; i < 32 ; i++)
    {
        [deviceId appendFormat:@"%02x", ptr[i]];
    }
    
    NSLog(@"Token : %@", deviceId);
    [[NSUserDefaults standardUserDefaults] setObject:deviceId forKey:@"pushToken"];
    [[NSUserDefaults standardUserDefaults] synchronize];

    
}

Process data after push is received

//push 수신 후 데이터 처리 
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{

    application.applicationIconBadgeNumber = 0;

    [CommonUtil showAlert:@"Push가 수신되었습니다"];


    NSLog(@"didReceiveRemoteNotification userInfo : %@", userInfo);

    NSString *str_Val = [userInfo objectForKey:@"spinpad"];
    if( str_Val && str_Val.length > 0 )
    {
        NSError *error = nil;

        NSData *data = [str_Val dataUsingEncoding:NSUTF8StringEncoding];
        NSDictionary *dic_Val = [NSJSONSerialization JSONObjectWithData:data
                                                                options:kNilOptions
                                                                  error:&error];
        id spinPad = [dic_Val objectForKey:@"spinpad"];
        if( spinPad != nil )
        {
            data = [spinPad dataUsingEncoding:NSUTF8StringEncoding];
            dic_Val = [NSJSONSerialization JSONObjectWithData:data
                                                      options:kNilOptions
                                                        error:&error];

            NSLog(@"spinpad pushInfo : %@", dic_Val);

            [[PASSIPADManager shared] setReceivePushData:dic_Val];

            UINavigationController *navi = (UINavigationController*)[[AppDelegate get].window rootViewController];

            ViewController *controller = (ViewController*)navi.topViewController;
            if( [controller respondsToSelector:@selector(checkBioAuth)] )
                [controller checkBioAuth];

        }
    }
}