| | |
| | | static NSString* sUserName; |
| | | static NSThread* _thread; |
| | | |
| | | //初始化状态,0初始化中,1成功,2登录 3登录注销 |
| | | //因为ios在sdk登录成功时游戏ModelCenter还没初始化好无法处理逻辑,需要在收到unity请求登录时检查状态2回复登录信息,状态3请求sdk登录 |
| | | //初始化状态,0初始化中,1成功 |
| | | static int initedState=0; |
| | | |
| | | static NSString * const kClientID = @"468442318367-ocoqrm0kei0gpkrnnq1ql628v4g4dbqd.apps.googleusercontent.com"; |
| | |
| | | [Soha sohaInitWithGameDelegate:self |
| | | application:[UIApplication sharedApplication] |
| | | launchOptions:launchOptions |
| | | loginManually:NO |
| | | loginManually:YES |
| | | andSetLanguageTo:SohaSDKLanguageVietnam]; |
| | | [Soha showInAppPopupTracking]; |
| | | |
| | |
| | | NSMutableDictionary *_dict = [NSMutableDictionary dictionaryWithObjectsAndKeys: |
| | | [NSNumber numberWithInt:S2U_DelAccount], @"code", nil]; |
| | | [self SendMessageToUnity:_dict]; |
| | | initedState=3; |
| | | } |
| | | } |
| | | |
| | |
| | | - (void)sohaLoginDelegate:(SohaUser *)user{ |
| | | if(user){ |
| | | NSLog(@"渠道登录成功"); |
| | | initedState=2; |
| | | NSString *account = [SohaUser currentUser].userId; |
| | | NSString *game_id = @"1"; |
| | | NSString *session_id = [SohaUser currentUser].accessToken; |
| | |
| | | else |
| | | { |
| | | NSLog(@"渠道登录失败"); |
| | | initedState=3; |
| | | } |
| | | } |
| | | |
| | |
| | | NSLog(@"渠道注销成功"); |
| | | NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:S2U_FreePlatformLogoutOk], @"code", nil]; |
| | | [self SendMessageToUnity:_dict]; |
| | | initedState=3; |
| | | } |
| | | |
| | | - (void)sohaDidPurchaseFailed:(SohaTransaction *)transaction purchaseError:(NSString *)error { |
| | |
| | | case 0: |
| | | break; |
| | | case 1: |
| | | [Soha sohaLoginSDK]; |
| | | break; |
| | | case 2: |
| | | { |
| | | NSString *account = [SohaUser currentUser].userId; |
| | | NSString *game_id = @"1"; |
| | | NSString *session_id = [SohaUser currentUser].accessToken; |
| | | |
| | | NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys: |
| | | [NSDictionary dictionaryWithObjectsAndKeys:account, @"account", |
| | | game_id, @"game_id", |
| | | session_id, @"session_id", nil],@"info", |
| | | [NSNumber numberWithInt:S2U_FreePlatformLoginOk], @"code", nil]; |
| | | [self SendMessageToUnity:_dict]; |
| | | break; |
| | | } |
| | | |
| | | default: |
| | | //ios特殊处理,sdk初始化比游戏快,导致游戏的sdk初始化值为false 需要在未登录处理 |
| | | [Soha sohaLoginSDK]; |
| | | break; |
| | | } |
| | | } |