| | |
| | | #endif |
| | | #import "SystemConfiguration/CaptiveNetwork.h" |
| | | #import <TTTracker/TTTracker+Game.h> |
| | | #import <AoyouSDK/AoyouSDK.h> |
| | | #import <AoyouSDK/IVQNAoyouSDK.h> |
| | | |
| | | @interface UniversalSDK()<JPUSHRegisterDelegate,UIWebViewDelegate> |
| | | @end |
| | |
| | | static int sBatteryState = -1; |
| | | static NSString* sAppID; |
| | | static NSString* sGameID; |
| | | static NSString* sUserName; |
| | | static NSThread* _thread; |
| | | |
| | | -(void) Init |
| | |
| | | // 今日头条 |
| | | NSDictionary* _infoDictionary = [[NSBundle mainBundle] infoDictionary]; |
| | | [TTTracker startWithAppID:_configDict[@"TTTrack_AppID"] |
| | | channel:@"ios-snqxz" |
| | | channel:@"ios-xbqy" |
| | | appName:[_infoDictionary objectForKey:@"CFBundleDisplayName"]]; |
| | | |
| | | // 发送初始化完成 |
| | |
| | | break; |
| | | case U2S_FreePlatformLogin: |
| | | { |
| | | [AoyouSDK loadLoginingVCResultSuccess:^(NSString * _Nonnull loginTime, NSString * _Nonnull userName, NSString * _Nonnull sign) { |
| | | [IVQNAoyouSDK ETTTloadLoginingVCResultSuccess:^(NSString * _Nonnull loginTime, NSString * _Nonnull userName, NSString * _Nonnull sign) { |
| | | NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys: |
| | | [NSDictionary dictionaryWithObjectsAndKeys:sign, @"token", |
| | | [NSString stringWithFormat:@"%@",loginTime], @"token_expire", |
| | | userName, @"account", nil],@"info", |
| | | [NSNumber numberWithInt:S2U_FreePlatformLoginOk], @"code", nil]; |
| | | sUserName = userName; |
| | | [self SendMessageToUnity:_dict]; |
| | | } failed:^(NSInteger code, NSString * _Nonnull message) { |
| | | NSLog(@"登录失败: code=%zd, msg=%@",code,message); |
| | |
| | | } |
| | | break; |
| | | case U2S_FreePlatformLogout: |
| | | [AoyouSDK LoginOut]; |
| | | { |
| | | [IVQNAoyouSDK ETTTloadLoginingVCResultSuccess:^(NSString * _Nonnull loginTime, NSString * _Nonnull userName, NSString * _Nonnull sign) { |
| | | NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys: |
| | | [NSDictionary dictionaryWithObjectsAndKeys:sign, @"token", |
| | | [NSString stringWithFormat:@"%@",loginTime], @"token_expire", |
| | | userName, @"account", nil],@"info", |
| | | [NSNumber numberWithInt:S2U_FreePlatformLoginOk], @"code", nil]; |
| | | sUserName = userName; |
| | | [self SendMessageToUnity:_dict]; |
| | | } failed:^(NSInteger code, NSString * _Nonnull message) { |
| | | NSLog(@"登录失败: code=%zd, msg=%@",code,message); |
| | | }]; |
| | | } |
| | | break; |
| | | case U2S_RoleLogin: |
| | | [AoyouSDK SetUserInfoWithRoleId:[NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleID"]] |
| | | roleName:[_dict objectForKey:@"roleName"] |
| | | roleLevel:[NSString stringWithFormat:@"%@",[_dict objectForKey:@"level"]] |
| | | zoneId:[NSString stringWithFormat:@"%@",[_dict objectForKey:@"sid"]] |
| | | zoneName:[_dict objectForKey:@"serverName"] |
| | | attach:@"" |
| | | block:^(NSInteger code) { |
| | | NSLog(@"---- code: %zd",code); |
| | | }]; |
| | | [IVQNAoyouSDK NFEGSetUserInfoWithRoleId:[NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleID"]] |
| | | roleName:[_dict objectForKey:@"roleName"] |
| | | roleLevel:[NSString stringWithFormat:@"%@",[_dict objectForKey:@"level"]] |
| | | zoneId:[NSString stringWithFormat:@"%@",[_dict objectForKey:@"sid"]] |
| | | zoneName:[_dict objectForKey:@"serverName"] |
| | | attach:@"" |
| | | block:^(NSInteger code) { |
| | | NSLog(@"---- code: %zd",code); |
| | | }]; |
| | | break; |
| | | case U2S_FreePlatformPay: |
| | | { |
| | | [AoyouSDK loadToFQVCWithRoleid:[_dict objectForKey:@"roleID"] |
| | | mo:[_dict objectForKey:@"mount"] |
| | | serverid:[_dict objectForKey:@"sid"] |
| | | productName:[_dict objectForKey:@"title"] |
| | | productDesc:[_dict objectForKey:@"title"] |
| | | attach:[NSString stringWithFormat:@"{\"appid\":\"%@\",\"cpinfo\":\"%@\",\"cporderid\":\"%@\",\"productid\":\"%@\"}", |
| | | sAppID, |
| | | [_dict objectForKey:@"cpInfo"], |
| | | [_dict objectForKey:@"orderId"], |
| | | sGameID] |
| | | productId:[_dict objectForKey:@"cpInfo"] |
| | | success:^(NSString * _Nonnull message, NSString * _Nonnull money) { |
| | | NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys: |
| | | [NSNumber numberWithInt:S2U_FreePlatformPayOk], @"code", nil]; |
| | | [self SendMessageToUnity:_dict]; |
| | | } faild:^(NSString * _Nonnull message, NSInteger code, NSString * _Nonnull money) { |
| | | NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys: |
| | | [NSNumber numberWithInt:S2U_FreePlatformPayFail], @"code", nil]; |
| | | [self SendMessageToUnity:_dict]; |
| | | }]; |
| | | [IVQNAoyouSDK KPTBloadToFQVCWithRoleid:[_dict objectForKey:@"roleID"] |
| | | mo:[_dict objectForKey:@"mount"] |
| | | serverid:[_dict objectForKey:@"sid"] |
| | | productName:[_dict objectForKey:@"title"] |
| | | productDesc:[_dict objectForKey:@"title"] |
| | | attach:[NSString stringWithFormat:@"{\"appid\":\"%@\",\"cpinfo\":\"%@\",\"cporderid\":\"%@\",\"productid\":\"%@\"}", |
| | | sAppID, |
| | | [_dict objectForKey:@"cpInfo"], |
| | | [_dict objectForKey:@"orderId"], |
| | | sGameID] |
| | | productId:[_dict objectForKey:@"cpInfo"] |
| | | success:^(NSString * _Nonnull message, NSString * _Nonnull money) { |
| | | NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys: |
| | | [NSNumber numberWithInt:S2U_FreePlatformPayOk], @"code", nil]; |
| | | [self SendMessageToUnity:_dict]; |
| | | } faild:^(NSString * _Nonnull message, NSInteger code, NSString * _Nonnull money) { |
| | | NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys: |
| | | [NSNumber numberWithInt:S2U_FreePlatformPayFail], @"code", nil]; |
| | | [self SendMessageToUnity:_dict]; |
| | | }]; |
| | | } |
| | | break; |
| | | case U2S_PayFinished: |
| | | [Tracking setRyzf:[_dict objectForKey:@"orderID"] |
| | | ryzfType:[_dict objectForKey:@"payType"] |
| | | hbType:[_dict objectForKey:@"moneyType"] |
| | | hbAmount:[_dict[@"money"] floatValue]]; |
| | | |
| | | [TTTracker purchaseEventWithContentType:@"mingwen" |
| | | contentName:@"yuanbao" |
| | | contentID:[_dict objectForKey:@"orderID"] |
| | | contentNumber:1 |
| | | paymentChannel:@"_defaul_" |
| | | currency:@"rmb" |
| | | currency_amount:[_dict[@"money"] intValue] |
| | | isSuccess:true]; |
| | | break; |
| | | case U2S_BatteryListenStart: |
| | | if(_thread == NULL) |
| | |
| | | } |
| | | break; |
| | | case U2S_BatteryListenStop: |
| | | |
| | | break; |
| | | case U2S_SendRegistEvent: |
| | | [Tracking setRegisterWithAccountID:sUserName]; |
| | | [TTTracker registerEventByMethod:@"_default_" isSuccess:true]; |
| | | break; |
| | | case U2S_SendLoginEvent: |
| | | [Tracking setLoginWithAccountID:sUserName]; |
| | | [TTTracker loginEventByMethod:@"_default_" isSuccess:true]; |
| | | break; |
| | | case U2S_JPushRemoveLocalMessage: |
| | | [self RemoveLocalNotificationWithIdentifierKey:_dict[@"id"]]; |