Commit f1dc4bfa90df6a0b7ac6d1dab37404ea8187590a
1 parent
ac91ee018a
Exists in
master
注销后自动登录时出现bug,游客登录时会加入用户名
Showing 5 changed files with 3 additions and 2 deletions Inline Diff
IOSDocument.md
| 1 | # Gump IOS SDK使用文档 | 1 | # Gump IOS SDK使用文档 | 
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | 接入手册 | 4 | 接入手册 | 
| 5 | V 3.4.3 | 5 | V 3.4.4 | 
| 6 | 2017年3月27日 | 6 | 2017年4月7日 | 
| 7 | 7 | ||
| 8 | ## 概述 | 8 | ## 概述 | 
| 9 | #### 本SDK提供gump账号,fb账号,vk账号三种账号登录,iap支付和第三方支付两种支付功能,其中gump账号登录和fb账号登录功能为必须接入,支付可根据需要选择性接入。 | 9 | #### 本SDK提供gump账号,fb账号,vk账号三种账号登录,iap支付和第三方支付两种支付功能,其中gump账号登录和fb账号登录功能为必须接入,支付可根据需要选择性接入。 | 
| 10 | 10 | ||
| 11 | ## 接入步骤 | 11 | ## 接入步骤 | 
| 12 | ### 1、添加Framework和资源文件 | 12 | ### 1、添加Framework和资源文件 | 
| 13 | + 以下为必须添加的framework以及资源bundle: | 13 | + 以下为必须添加的framework以及资源bundle: | 
| 14 | MobileCoreServices.framework、SystemConfiguration.framework、libz.dylib、CFNetwork.framework、GameSDK.framework、StoreKit.framework、GameSDKResources.bundle | 14 | MobileCoreServices.framework、SystemConfiguration.framework、libz.dylib、CFNetwork.framework、GameSDK.framework、StoreKit.framework、GameSDKResources.bundle | 
| 15 | + 以下为可选,若接入vk登录则需要添加以下framework和bundle,其中VKSdk.framework和VKSDKResources.bundle请自行从vk.com下载,使用1.3版本 | 15 | + 以下为可选,若接入vk登录则需要添加以下framework和bundle,其中VKSdk.framework和VKSDKResources.bundle请自行从vk.com下载,使用1.3版本 | 
| 16 | VKSdk.framework、VKBridge.framework、VKSDKResources.bundle | 16 | VKSdk.framework、VKBridge.framework、VKSDKResources.bundle | 
| 17 | + 以下为可选,若接入bluePay第三方支付方式需要添加一下的framework和bundle,其中CoreBuePay.framework直接引入工程,之后再依次引入CoreTelephony.framework、MessageUI.framework、SystemConfiguration.framework,最后将BlueMobile.bundle拖入项目中 | 17 | + 以下为可选,若接入bluePay第三方支付方式需要添加一下的framework和bundle,其中CoreBuePay.framework直接引入工程,之后再依次引入CoreTelephony.framework、MessageUI.framework、SystemConfiguration.framework,最后将BlueMobile.bundle拖入项目中 | 
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | ### 2、引入头文件,设置build setting | 20 | ### 2、引入头文件,设置build setting | 
| 21 | 需要使用头文件有LetsGameAPI.h和VKBridge.h,其中VKBridge.h为接入vk时使用,不接入vk可忽略。 | 21 | 需要使用头文件有LetsGameAPI.h和VKBridge.h,其中VKBridge.h为接入vk时使用,不接入vk可忽略。 | 
| 22 | 因sdk内使用了category,需要设置other linker flag为 -ObjC | 22 | 因sdk内使用了category,需要设置other linker flag为 -ObjC | 
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | ### 3、增加必要配置 | 25 | ### 3、增加必要配置 | 
| 26 | 1)在application delegate中, 在application:openURL:sourceApplication:annotation:添加返回: | 26 | 1)在application delegate中, 在application:openURL:sourceApplication:annotation:添加返回: | 
| 27 | 27 | ||
| 28 | return [[LetsGameAPI instance] handleOpenURL:url sourceApplication:sourceApplication]; | 28 | return [[LetsGameAPI instance] handleOpenURL:url sourceApplication:sourceApplication]; | 
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | 2)配置URL-schema(vk专用,不接入vk可忽略) | 31 | 2)配置URL-schema(vk专用,不接入vk可忽略) | 
| 32 | Xcode 5: Open your application settings then select the Info tab. In the URL Types section click the plus sign. Enter vk+APP_ID (e.g. vk1234567) to the Identifier and URL Schemes fields. | 32 | Xcode 5: Open your application settings then select the Info tab. In the URL Types section click the plus sign. Enter vk+APP_ID (e.g. vk1234567) to the Identifier and URL Schemes fields. | 
| 33 |  | 33 |  | 
| 34 | Xcode 4: Open your Info.plist then add a new row URL Types. Set the URL identifier to vk+APP_ID | 34 | Xcode 4: Open your Info.plist then add a new row URL Types. Set the URL identifier to vk+APP_ID | 
| 35 |  | 35 |  | 
| 36 | 36 | ||
| 37 | 3)配置plist和scheme(BluePay的linePay使用,不接入BluePay的LinePay可忽略) | 37 | 3)配置plist和scheme(BluePay的linePay使用,不接入BluePay的LinePay可忽略) | 
| 38 | 38 | ||
| 39 | plist部分: | 39 | plist部分: | 
| 40 | <key>LSApplicationQueriesSchemes</key> | 40 | <key>LSApplicationQueriesSchemes</key> | 
| 41 | <array> | 41 | <array> | 
| 42 | <string>line</string> | 42 | <string>line</string> | 
| 43 | </array> | 43 | </array> | 
| 44 | scheme部分: | 44 | scheme部分: | 
| 45 | <key>CFBundleURLTypes</key> | 45 | <key>CFBundleURLTypes</key> | 
| 46 | <array> | 46 | <array> | 
| 47 | <dict> | 47 | <dict> | 
| 48 | <key>CFBundleTypeRole</key> | 48 | <key>CFBundleTypeRole</key> | 
| 49 | <string>None</string> | 49 | <string>None</string> | 
| 50 | <key>CFBundleURLName</key> | 50 | <key>CFBundleURLName</key> | 
| 51 | <string>com.gump.sdk</string> | 51 | <string>com.gump.sdk</string> | 
| 52 | <key>CFBundleURLSchemes</key> | 52 | <key>CFBundleURLSchemes</key> | 
| 53 | <array> | 53 | <array> | 
| 54 | <string> gump+游戏的appId </string> | 54 | <string> gump+游戏的appId </string> | 
| 55 | </array> | 55 | </array> | 
| 56 | </dict> | 56 | </dict> | 
| 57 | </array> | 57 | </array> | 
| 58 | ### 4、在工程里添加SDK登录代码 | 58 | ### 4、在工程里添加SDK登录代码 | 
| 59 | 59 | ||
| 60 | [LetsGameAPI instance].appId = @"100"; // 设置appId | 60 | [LetsGameAPI instance].appId = @"100"; // 设置appId | 
| 61 | [LetsGameAPI instance].appKey = @"100"; // 设置appKey | 61 | [LetsGameAPI instance].appKey = @"100"; // 设置appKey | 
| 62 | 62 | ||
| 63 | //启用vk的代码,需要填入vk appId,若不接入vk,可以忽略 | 63 | //启用vk的代码,需要填入vk appId,若不接入vk,可以忽略 | 
| 64 | //VKBridge *vkBridge = [[VKBridge alloc] initWithVKAppId:@"5029792"]; | 64 | //VKBridge *vkBridge = [[VKBridge alloc] initWithVKAppId:@"5029792"]; | 
| 65 | //[LetsGameAPI instance].vkBridge = vkBridge; | 65 | //[LetsGameAPI instance].vkBridge = vkBridge; | 
| 66 | 66 | ||
| 67 | //隐藏fb登录 | 67 | //隐藏fb登录 | 
| 68 | [LetsGameAPI disableFB:YES]; | 68 | [LetsGameAPI disableFB:YES]; | 
| 69 | 69 | ||
| 70 | //隐藏gumptech的logo | 70 | //隐藏gumptech的logo | 
| 71 | [LetsGameAPI hiddenLogo:YES]; | 71 | [LetsGameAPI hiddenLogo:YES]; | 
| 72 | 72 | ||
| 73 | [[LetsGameAPI instance] showLoginView]; // 弹出登录页面 | 73 | [[LetsGameAPI instance] showLoginView]; // 弹出登录页面 | 
| 74 | 74 | ||
| 75 | // 登录成功回调 | 75 | // 登录成功回调 | 
| 76 | [LetsGameAPI instance].succBlock = ^(NSString *userId, NSString *sessionKey, LSGAccountType type) { | 76 | [LetsGameAPI instance].succBlock = ^(NSString *userId, NSString *sessionKey, LSGAccountType type) { | 
| 77 | NSLog(@"%@", [NSString stringWithFormat:@"login succ: userId = %@, sessionKey = %@, accountType = %d", userId, sessionKey, type]); | 77 | NSLog(@"%@", [NSString stringWithFormat:@"login succ: userId = %@, sessionKey = %@, accountType = %d", userId, sessionKey, type]); | 
| 78 | }; | 78 | }; | 
| 79 | 79 | ||
| 80 | // 登录失败回调 | 80 | // 登录失败回调 | 
| 81 | [LetsGameAPI instance].dismissBlock = ^() { | 81 | [LetsGameAPI instance].dismissBlock = ^() { | 
| 82 | NSLog(@"dismiss without login"); | 82 | NSLog(@"dismiss without login"); | 
| 83 | }; | 83 | }; | 
| 84 | 84 | ||
| 85 | ### 5、登录注销 | 85 | ### 5、登录注销 | 
| 86 | 注销接口只要设置过appId和appKey之后就不需要设置了,注销完成之后会回到登录界面。FB登录回到登录页面,Gump登录或者游客登录回到登录框。 | 86 | 注销接口只要设置过appId和appKey之后就不需要设置了,注销完成之后会回到登录界面。FB登录回到登录页面,Gump登录或者游客登录回到登录框。 | 
| 87 | 87 | ||
| 88 | [LetsGameAPI instance].appId = @"100";//设置appId | 88 | [LetsGameAPI instance].appId = @"100";//设置appId | 
| 89 | [LetsGameAPI instance].appKey = @"100";//设置appkey | 89 | [LetsGameAPI instance].appKey = @"100";//设置appkey | 
| 90 | [[LetsGameAPI instance] logout]; //注销 | 90 | [[LetsGameAPI instance] logout]; //注销 | 
| 91 | 91 | ||
| 92 | 92 | ||
| 93 | ### 6、第三方支付 | 93 | ### 6、第三方支付 | 
| 94 | [LetsGameAPI instance].appId = @"10022"; | 94 | [LetsGameAPI instance].appId = @"10022"; | 
| 95 | [LetsGameAPI instance].appKey = @"f899139df5e1059396431415e770c6dd"; | 95 | [LetsGameAPI instance].appKey = @"f899139df5e1059396431415e770c6dd"; | 
| 96 | NSMutableDictionary *payInfo = [NSMutableDictionary dictionary]; | 96 | NSMutableDictionary *payInfo = [NSMutableDictionary dictionary]; | 
| 97 | [payInfo setValue:@"5001" forKey:@"serverId"];//服务器id,必传参数 | 97 | [payInfo setValue:@"5001" forKey:@"serverId"];//服务器id,必传参数 | 
| 98 | [payInfo setValue:@"10010" forKey:@"roleId"];//用户角色id | 98 | [payInfo setValue:@"10010" forKey:@"roleId"];//用户角色id | 
| 99 | [payInfo setValue:@"1000" forKey:@"channelId"];//渠道id | 99 | [payInfo setValue:@"1000" forKey:@"channelId"];//渠道id | 
| 100 | [payInfo setValue:@"10" forKey:@"amount"];//金额 | 100 | [payInfo setValue:@"10" forKey:@"amount"];//金额 | 
| 101 | [payInfo setValue:@"ios demo" forKey:@"extraInfo"];//外部订单信息 | 101 | [payInfo setValue:@"ios demo" forKey:@"extraInfo"];//外部订单信息 | 
| 102 | [payInfo setValue:@"元宝" forKey:@"product"];//物品信息 | 102 | [payInfo setValue:@"元宝" forKey:@"product"];//物品信息 | 
| 103 | [payInfo setValue:self.sessionKey forKey:@"sessionKey"];//登录成功的sessionKey | 103 | [payInfo setValue:self.sessionKey forKey:@"sessionKey"];//登录成功的sessionKey | 
| 104 | [[LetsGameAPI instance] pay:payInfo handleCallBack:^{ | 104 | [[LetsGameAPI instance] pay:payInfo handleCallBack:^{ | 
| 105 | //第三方支付完成时的回调(包括支付成功和支付失败,除了支付过程中取消的),取消的不会有回调 | 105 | //第三方支付完成时的回调(包括支付成功和支付失败,除了支付过程中取消的),取消的不会有回调 | 
| 106 | NSLog(@"第三方支付完成"); | 106 | NSLog(@"第三方支付完成"); | 
| 107 | }]]; | 107 | }]]; | 
| 108 | 108 | ||
| 109 | ### 7、IAP支付 | 109 | ### 7、IAP支付 | 
| 110 | 若要使用apple IAP支付,需要在AppDelegate的application: didFinishLaunchingWithOptions:方法内注册iap observer,使用如下方法 | 110 | 若要使用apple IAP支付,需要在AppDelegate的application: didFinishLaunchingWithOptions:方法内注册iap observer,使用如下方法 | 
| 111 | 111 | ||
| 112 | [[LetsGameAPI instance] registeIapObserver]; | 112 | [[LetsGameAPI instance] registeIapObserver]; | 
| 113 | 具体调用iap支付的方法如下: | 113 | 具体调用iap支付的方法如下: | 
| 114 | 114 | ||
| 115 | [LetsGameAPI instance].appId = @"10022"; | 115 | [LetsGameAPI instance].appId = @"10022"; | 
| 116 | [LetsGameAPI instance].appKey = @"93a27b0bd99bac3e68a440b48aa421ab"; | 116 | [LetsGameAPI instance].appKey = @"93a27b0bd99bac3e68a440b48aa421ab"; | 
| 117 | NSMutableDictionary *payInfo = [NSMutableDictionary dictionary]; | 117 | NSMutableDictionary *payInfo = [NSMutableDictionary dictionary]; | 
| 118 | [payInfo setValue:@"5001" forKey:@"serverId"];//当前用户所在的服务器Id | 118 | [payInfo setValue:@"5001" forKey:@"serverId"];//当前用户所在的服务器Id | 
| 119 | [payInfo setValue:@"10010" forKey:@"roleId"];//当前用户的角色id | 119 | [payInfo setValue:@"10010" forKey:@"roleId"];//当前用户的角色id | 
| 120 | [payInfo setValue:@"1000" forKey:@"channelId"];//渠道id,用于统计 | 120 | [payInfo setValue:@"1000" forKey:@"channelId"];//渠道id,用于统计 | 
| 121 | [payInfo setValue:@"10" forKey:@"amount"];//对应支付项的支付金额,实际支付金额以itunes配置为准 | 121 | [payInfo setValue:@"10" forKey:@"amount"];//对应支付项的支付金额,实际支付金额以itunes配置为准 | 
| 122 | [payInfo setValue:@"ios demo" forKey:@"extraInfo"];//扩展信息,可以游戏自定义,建议传自有订单号 | 122 | [payInfo setValue:@"ios demo" forKey:@"extraInfo"];//扩展信息,可以游戏自定义,建议传自有订单号 | 
| 123 | [payInfo setValue:@"test.product.1" forKey:@"product"];//itunes 后台配置的对应支付项的productId | 123 | [payInfo setValue:@"test.product.1" forKey:@"product"];//itunes 后台配置的对应支付项的productId | 
| 124 | [[LetsGameAPI instance] iap:payInfo forUser:@"" handleCallback:^(NSString* orderId){ | 124 | [[LetsGameAPI instance] iap:payInfo forUser:@"" handleCallback:^(NSString* orderId){ | 
| 125 | //此处的回调表明支付已经完成,但此时支付不一定成功,需要服务端验证支付结果 | 125 | //此处的回调表明支付已经完成,但此时支付不一定成功,需要服务端验证支付结果 | 
| 126 | //orderId为gump生成的订单号,此订单号可以在gump server查询此笔支付是否成功 | 126 | //orderId为gump生成的订单号,此订单号可以在gump server查询此笔支付是否成功 | 
| 127 | NSLog(@"iap completed orderId of gumptech:%@",orderId); | 127 | NSLog(@"iap completed orderId of gumptech:%@",orderId); | 
| 128 | }]; | 128 | }]; | 
| 129 | ### 8、token的获取 | 129 | ### 8、token的获取 | 
| 130 | FB登录之后会产生token并自动登录,需要如果需要token的话,需要自己调用接口获取。 | 130 | FB登录之后会产生token并自动登录,需要如果需要token的话,需要自己调用接口获取。 | 
| 131 | 131 | ||
| 132 | //tokenString:token字符串 | 132 | //tokenString:token字符串 | 
| 133 | //refreshTime:refreshTime token最后刷新的时间,即获取的token的时间 | 133 | //refreshTime:refreshTime token最后刷新的时间,即获取的token的时间 | 
| 134 | //expirationTime:expirationTime token最后的有效时间 | 134 | //expirationTime:expirationTime token最后的有效时间 | 
| 135 | [[LetsGameAPI instance] obtainAccessTokenSuccess:^(NSString *tokenString, NSString *refreshTime, NSString *expirationTime) { | 135 | [[LetsGameAPI instance] obtainAccessTokenSuccess:^(NSString *tokenString, NSString *refreshTime, NSString *expirationTime) { | 
| 136 | NSLog(@"tokenString %@, refreshTime %@, expirationTime %@", tokenString, refreshTime, expirationTime); | 136 | NSLog(@"tokenString %@, refreshTime %@, expirationTime %@", tokenString, refreshTime, expirationTime); | 
| 137 | } failure:^(NSString *errorString) { | 137 | } failure:^(NSString *errorString) { | 
| 138 | NSLog(@"get token faile"); | 138 | NSLog(@"get token faile"); | 
| 139 | }]; | 139 | }]; | 
| 140 | 140 | ||
| 141 | 141 | ||
| 142 | ### 9、第三方支付版本 | 142 | ### 9、第三方支付版本 | 
| 143 | 第三方支付,分成两个版本:没有gump币和有gump币,不设置时默认为带gump币版本,如果使用不带gump币的版本如下设置: | 143 | 第三方支付,分成两个版本:没有gump币和有gump币,不设置时默认为带gump币版本,如果使用不带gump币的版本如下设置: | 
| 144 | 144 | ||
| 145 | 需要在 application:didFinishLaunchingWithOptions方法中添加: | 145 | 需要在 application:didFinishLaunchingWithOptions方法中添加: | 
| 146 | 146 | ||
| 147 | [[LetsGameAPI instance] decideWebPayVersion:1] | 147 | [[LetsGameAPI instance] decideWebPayVersion:1] | 
| 148 | 148 | ||
| 149 | 149 | ||
| 150 | ### 10、关于侵权还是侵权的接口显示 | 150 | ### 10、关于侵权还是侵权的接口显示 | 
| 151 | 运营在后台配置此包名和版本在什么时候显示侵权内容还是不侵权内容,此接口调用需要在游戏才开始加载的时候调用,返回值是YES的时候显示侵权内容,在NO的时候显示不侵权内容。 | 151 | 运营在后台配置此包名和版本在什么时候显示侵权内容还是不侵权内容,此接口调用需要在游戏才开始加载的时候调用,返回值是YES的时候显示侵权内容,在NO的时候显示不侵权内容。 | 
| 152 | 152 | ||
| 153 | 注意:关于运营配置的游戏的版本号,我们默认取的是Bulid版本号的值,请注意。 | 153 | 注意:关于运营配置的游戏的版本号,我们默认取的是Bulid版本号的值,请注意。 | 
| 154 | 154 | ||
| 155 | [[LetsGameAPI instance] gameObtainSafeSetInfoWithAppId:@"10056" ChannelId:@"1000" handleCallBack:^(BOOL resultStatus) { | 155 | [[LetsGameAPI instance] gameObtainSafeSetInfoWithAppId:@"10056" ChannelId:@"1000" handleCallBack:^(BOOL resultStatus) { | 
| 156 | if (resultStatus) { | 156 | if (resultStatus) { | 
| 157 | NSLog(@"YES 侵权"); | 157 | NSLog(@"YES 侵权"); | 
| 158 | }else{ | 158 | }else{ | 
| 159 | NSLog(@"NO 不侵权"); | 159 | NSLog(@"NO 不侵权"); | 
| 160 | } | 160 | } | 
| 161 | }]; | 161 | }]; | 
| 162 | 162 | ||
| 163 | 163 | ||
| 164 | 164 | 
ios/GameSDK.framework/Versions/A/GameSDK
No preview for this file type
ios/GameSDK.zip
No preview for this file type
ios/GameSDKDemo/GameSDKDemo.xcodeproj/project.xcworkspace/xcuserdata/yanglele.xcuserdatad/UserInterfaceState.xcuserstate
No preview for this file type
ios/GameSDKDemo/letsgameDemo/LSGMainViewController.m
| 1 | // | 1 | // | 
| 2 | // LSGMainViewController.m | 2 | // LSGMainViewController.m | 
| 3 | // letsgameDemo | 3 | // letsgameDemo | 
| 4 | // | 4 | // | 
| 5 | // Created by zhy on 14-5-24. | 5 | // Created by zhy on 14-5-24. | 
| 6 | // | 6 | // | 
| 7 | // | 7 | // | 
| 8 | 8 | ||
| 9 | #import "LSGMainViewController.h" | 9 | #import "LSGMainViewController.h" | 
| 10 | #import "LetsGameAPI.h" | 10 | #import "LetsGameAPI.h" | 
| 11 | #import "VKBridge.h" | 11 | #import "VKBridge.h" | 
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | @interface LSGMainViewController () | 14 | @interface LSGMainViewController () | 
| 15 | 15 | ||
| 16 | @property (nonatomic, strong) UILabel *resultLabel; | 16 | @property (nonatomic, strong) UILabel *resultLabel; | 
| 17 | 17 | ||
| 18 | @property(nonatomic,strong) UIButton *vkActivityShareBtn; | 18 | @property(nonatomic,strong) UIButton *vkActivityShareBtn; | 
| 19 | 19 | ||
| 20 | @property(nonatomic,copy) NSString *sessionKey; | 20 | @property(nonatomic,copy) NSString *sessionKey; | 
| 21 | @end | 21 | @end | 
| 22 | 22 | ||
| 23 | @implementation LSGMainViewController | 23 | @implementation LSGMainViewController | 
| 24 | 24 | ||
| 25 | - (void)loadView { | 25 | - (void)loadView { | 
| 26 | [super loadView]; | 26 | [super loadView]; | 
| 27 | NSLog(@"i come in"); | 27 | NSLog(@"i come in"); | 
| 28 | self.view.backgroundColor = [UIColor whiteColor]; | 28 | self.view.backgroundColor = [UIColor whiteColor]; | 
| 29 | // self.view.backgroundColor = [UIColor blackColor]; | 29 | // self.view.backgroundColor = [UIColor blackColor]; | 
| 30 | 30 | ||
| 31 | UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(110, 40, 100, 30)]; | 31 | UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(110, 40, 100, 30)]; | 
| 32 | btn.backgroundColor = [UIColor orangeColor]; | 32 | btn.backgroundColor = [UIColor orangeColor]; | 
| 33 | [btn setTitle:@"测试入口" forState:UIControlStateNormal]; | 33 | [btn setTitle:@"测试入口" forState:UIControlStateNormal]; | 
| 34 | [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | 34 | [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | 
| 35 | btn.titleLabel.font = [UIFont systemFontOfSize:15]; | 35 | btn.titleLabel.font = [UIFont systemFontOfSize:15]; | 
| 36 | [btn addTarget:self action:@selector(onClickTest) forControlEvents:UIControlEventTouchUpInside]; | 36 | [btn addTarget:self action:@selector(onClickTest) forControlEvents:UIControlEventTouchUpInside]; | 
| 37 | [self.view addSubview:btn]; | 37 | [self.view addSubview:btn]; | 
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | 40 | ||
| 41 | UIButton *bindtn = [[UIButton alloc] initWithFrame:CGRectMake(110, 100, 100, 30)]; | 41 | UIButton *bindtn = [[UIButton alloc] initWithFrame:CGRectMake(110, 100, 100, 30)]; | 
| 42 | bindtn.backgroundColor = [UIColor orangeColor]; | 42 | bindtn.backgroundColor = [UIColor orangeColor]; | 
| 43 | [bindtn setTitle:@"退出账号" forState:UIControlStateNormal]; | 43 | [bindtn setTitle:@"退出账号" forState:UIControlStateNormal]; | 
| 44 | [bindtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | 44 | [bindtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | 
| 45 | bindtn.titleLabel.font = [UIFont systemFontOfSize:15]; | 45 | bindtn.titleLabel.font = [UIFont systemFontOfSize:15]; | 
| 46 | [bindtn addTarget:self action:@selector(onLogoutTest) forControlEvents:UIControlEventTouchUpInside]; | 46 | [bindtn addTarget:self action:@selector(onLogoutTest) forControlEvents:UIControlEventTouchUpInside]; | 
| 47 | [self.view addSubview:bindtn]; | 47 | [self.view addSubview:bindtn]; | 
| 48 | 48 | ||
| 49 | UIButton *payBtn = [[UIButton alloc] initWithFrame:CGRectMake(110, 160, 100, 30)]; | 49 | UIButton *payBtn = [[UIButton alloc] initWithFrame:CGRectMake(110, 160, 100, 30)]; | 
| 50 | payBtn.backgroundColor = [UIColor orangeColor]; | 50 | payBtn.backgroundColor = [UIColor orangeColor]; | 
| 51 | [payBtn setTitle:@"支付" forState:UIControlStateNormal]; | 51 | [payBtn setTitle:@"支付" forState:UIControlStateNormal]; | 
| 52 | [payBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | 52 | [payBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | 
| 53 | payBtn.titleLabel.font = [UIFont systemFontOfSize:15]; | 53 | payBtn.titleLabel.font = [UIFont systemFontOfSize:15]; | 
| 54 | [payBtn addTarget:self action:@selector(onPayTest) forControlEvents:UIControlEventTouchUpInside]; | 54 | [payBtn addTarget:self action:@selector(onPayTest) forControlEvents:UIControlEventTouchUpInside]; | 
| 55 | [self.view addSubview:payBtn]; | 55 | [self.view addSubview:payBtn]; | 
| 56 | 56 | ||
| 57 | UIButton *iapBtn = [[UIButton alloc] initWithFrame:CGRectMake(110, 220, 100, 30)]; | 57 | UIButton *iapBtn = [[UIButton alloc] initWithFrame:CGRectMake(110, 220, 100, 30)]; | 
| 58 | iapBtn.backgroundColor = [UIColor orangeColor]; | 58 | iapBtn.backgroundColor = [UIColor orangeColor]; | 
| 59 | [iapBtn setTitle:@"IAP" forState:UIControlStateNormal]; | 59 | [iapBtn setTitle:@"IAP" forState:UIControlStateNormal]; | 
| 60 | [iapBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | 60 | [iapBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | 
| 61 | iapBtn.titleLabel.font = [UIFont systemFontOfSize:15]; | 61 | iapBtn.titleLabel.font = [UIFont systemFontOfSize:15]; | 
| 62 | [iapBtn addTarget:self action:@selector(onIapTest) forControlEvents:UIControlEventTouchUpInside]; | 62 | [iapBtn addTarget:self action:@selector(onIapTest) forControlEvents:UIControlEventTouchUpInside]; | 
| 63 | [self.view addSubview:iapBtn]; | 63 | [self.view addSubview:iapBtn]; | 
| 64 | 64 | ||
| 65 | } | 65 | } | 
| 66 | 66 | ||
| 67 | - (UILabel *)resultLabel { | 67 | - (UILabel *)resultLabel { | 
| 68 | if (!_resultLabel) { | 68 | if (!_resultLabel) { | 
| 69 | _resultLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.view.frame) - 90, self.view.frame.size.width, 60)]; | 69 | _resultLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.view.frame) - 90, self.view.frame.size.width, 60)]; | 
| 70 | _resultLabel.backgroundColor = [UIColor clearColor]; | 70 | _resultLabel.backgroundColor = [UIColor clearColor]; | 
| 71 | _resultLabel.textAlignment = NSTextAlignmentCenter; | 71 | _resultLabel.textAlignment = NSTextAlignmentCenter; | 
| 72 | _resultLabel.textColor = [UIColor redColor]; | 72 | _resultLabel.textColor = [UIColor redColor]; | 
| 73 | _resultLabel.font = [UIFont systemFontOfSize:15]; | 73 | _resultLabel.font = [UIFont systemFontOfSize:15]; | 
| 74 | _resultLabel.numberOfLines = 4; | 74 | _resultLabel.numberOfLines = 4; | 
| 75 | _resultLabel.lineBreakMode = NSLineBreakByWordWrapping; | 75 | _resultLabel.lineBreakMode = NSLineBreakByWordWrapping; | 
| 76 | [self.view addSubview:_resultLabel]; | 76 | [self.view addSubview:_resultLabel]; | 
| 77 | } | 77 | } | 
| 78 | 78 | ||
| 79 | return _resultLabel; | 79 | return _resultLabel; | 
| 80 | } | 80 | } | 
| 81 | 81 | ||
| 82 | 82 | ||
| 83 | - (void)onClickTest { | 83 | - (void)onClickTest { | 
| 84 | 84 | ||
| 85 | [LetsGameAPI instance].appId = @"10056";//10047 | 85 | [LetsGameAPI instance].appId = @"10056";//10047 | 
| 86 | [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21";//eccd9f7dc92858b741132fda313130cf | 86 | [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21";//eccd9f7dc92858b741132fda313130cf | 
| 87 | [LetsGameAPI hiddenLogo:YES]; | 87 | [LetsGameAPI hiddenLogo:YES]; | 
| 88 | // [LetsGameAPI disableFB:NO]; | 88 | // [LetsGameAPI disableFB:NO]; | 
| 89 | NSLog(@"sdk version:%@",[[LetsGameAPI instance] version]); | 89 | NSLog(@"sdk version:%@",[[LetsGameAPI instance] version]); | 
| 90 | //启用vk登录 | 90 | //启用vk登录 | 
| 91 | VKBridge *vkBridge = [[VKBridge alloc] initWithVKAppId:@"5029792"]; | 91 | VKBridge *vkBridge = [[VKBridge alloc] initWithVKAppId:@"5029792"]; | 
| 92 | [LetsGameAPI instance].vkBridge = vkBridge; | 92 | [LetsGameAPI instance].vkBridge = vkBridge; | 
| 93 | 93 | ||
| 94 | [LetsGameAPI instance].succBlock = ^(NSString *userId, NSString *sessionKey, LSGAccountType type) { | 94 | [LetsGameAPI instance].succBlock = ^(NSString *userId, NSString *sessionKey, LSGAccountType type) { | 
| 95 | self.sessionKey = sessionKey; | 95 | self.sessionKey = sessionKey; | 
| 96 | self.resultLabel.text = [NSString stringWithFormat:@"login succ: userId = %@, sessionKey = %@, accountType = %ld", userId, sessionKey, type]; | 96 | self.resultLabel.text = [NSString stringWithFormat:@"login succ: userId = %@, sessionKey = %@, accountType = %ld", userId, sessionKey, type]; | 
| 97 | }; | 97 | }; | 
| 98 | [LetsGameAPI instance].dismissBlock = ^() { | 98 | [LetsGameAPI instance].dismissBlock = ^() { | 
| 99 | self.resultLabel.text = @"dismiss without login"; | 99 | self.resultLabel.text = @"dismiss without login"; | 
| 100 | }; | 100 | }; | 
| 101 | 101 | ||
| 102 | [[LetsGameAPI instance] showLoginView]; | 102 | [[LetsGameAPI instance] showLoginView]; | 
| 103 | } | 103 | } | 
| 104 | 104 | ||
| 105 | 105 | ||
| 106 | - (void)onLogoutTest { | 106 | - (void)onLogoutTest { | 
| 107 | [LetsGameAPI instance].appId = @"10056"; | 107 | [LetsGameAPI instance].appId = @"10056"; | 
| 108 | [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21"; | 108 | [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21"; | 
| 109 | [[LetsGameAPI instance] logout]; | 109 | [[LetsGameAPI instance] logout]; | 
| 110 | 110 | ||
| 111 | } | 111 | } | 
| 112 | 112 | ||
| 113 | -(void)onPayTest{ | 113 | -(void)onPayTest{ | 
| 114 | [LetsGameAPI instance].appId = @"10056";//10022 | 114 | [LetsGameAPI instance].appId = @"10056";//10022 | 
| 115 | [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21";//93a27b0bd99bac3e68a440b48aa421ab | 115 | [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21";//93a27b0bd99bac3e68a440b48aa421ab | 
| 116 | NSMutableDictionary *payInfo = [NSMutableDictionary dictionary]; | 116 | NSMutableDictionary *payInfo = [NSMutableDictionary dictionary]; | 
| 117 | [payInfo setValue:@"100" forKey:@"serverId"]; | 117 | [payInfo setValue:@"100" forKey:@"serverId"]; | 
| 118 | [payInfo setValue:@"10010" forKey:@"roleId"]; | 118 | [payInfo setValue:@"10010" forKey:@"roleId"]; | 
| 119 | [payInfo setValue:@"1000" forKey:@"channelId"]; | 119 | [payInfo setValue:@"1000" forKey:@"channelId"]; | 
| 120 | [payInfo setValue:@"10" forKey:@"amount"]; | 120 | [payInfo setValue:@"10" forKey:@"amount"]; | 
| 121 | [payInfo setValue:@"ios demo" forKey:@"extraInfo"]; | 121 | [payInfo setValue:@"ios demo" forKey:@"extraInfo"]; | 
| 122 | [payInfo setValue:@"test" forKey:@"product"]; | 122 | [payInfo setValue:@"test" forKey:@"product"]; | 
| 123 | [payInfo setValue:@"76c17cc68ff9f7f40bd3d096ccc5600a" forKey:@"sessionKey"]; //self.sessionKey | 123 | [payInfo setValue:@"76c17cc68ff9f7f40bd3d096ccc5600a" forKey:@"sessionKey"]; //self.sessionKey | 
| 124 | [[LetsGameAPI instance] pay:payInfo handleCallBack:^{ | 124 | [[LetsGameAPI instance] pay:payInfo handleCallBack:^{ | 
| 125 | NSLog(@"第三方支付完成"); | 125 | NSLog(@"第三方支付完成"); | 
| 126 | }]; | 126 | }]; | 
| 127 | } | 127 | } | 
| 128 | 128 | ||
| 129 | -(void)onIapTest{ | 129 | -(void)onIapTest{ | 
| 130 | |||
| 130 | [LetsGameAPI instance].appId = @"10056"; | 131 | [LetsGameAPI instance].appId = @"10056"; | 
| 131 | [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21"; | 132 | [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21"; | 
| 132 | NSMutableDictionary *payInfo = [NSMutableDictionary dictionary]; | 133 | NSMutableDictionary *payInfo = [NSMutableDictionary dictionary]; | 
| 133 | [payInfo setValue:@"5001" forKey:@"serverId"]; | 134 | [payInfo setValue:@"5001" forKey:@"serverId"]; | 
| 134 | [payInfo setValue:@"10010" forKey:@"roleId"]; | 135 | [payInfo setValue:@"10010" forKey:@"roleId"]; | 
| 135 | [payInfo setValue:@"1000" forKey:@"channelId"]; | 136 | [payInfo setValue:@"1000" forKey:@"channelId"]; | 
| 136 | [payInfo setValue:@"10" forKey:@"amount"]; | 137 | [payInfo setValue:@"10" forKey:@"amount"]; | 
| 137 | [payInfo setValue:@"ios demo" forKey:@"extraInfo"]; | 138 | [payInfo setValue:@"ios demo" forKey:@"extraInfo"]; | 
| 138 | [payInfo setValue:@"test.product.1" forKey:@"product"]; | 139 | [payInfo setValue:@"test.product.1" forKey:@"product"]; | 
| 139 | [[LetsGameAPI instance] iap:payInfo forUser:@"" handleCallback:^(NSString* orderId){ | 140 | [[LetsGameAPI instance] iap:payInfo forUser:@"" handleCallback:^(NSString* orderId){ | 
| 140 | NSLog(@"IAP completed orderId of Gumptech:%@",orderId); | 141 | NSLog(@"IAP completed orderId of Gumptech:%@",orderId); | 
| 141 | }]; | 142 | }]; | 
| 142 | } | 143 | } | 
| 143 | 144 | ||
| 144 | 145 | ||
| 145 | - (BOOL)shouldAutorotate { | 146 | - (BOOL)shouldAutorotate { | 
| 146 | return YES; | 147 | return YES; | 
| 147 | } | 148 | } | 
| 148 | 149 | ||
| 149 | -(UIInterfaceOrientationMask)supportedInterfaceOrientations{ | 150 | -(UIInterfaceOrientationMask)supportedInterfaceOrientations{ | 
| 150 | return UIInterfaceOrientationMaskAll; | 151 | return UIInterfaceOrientationMaskAll; | 
| 151 | } | 152 | } | 
| 152 | 153 | ||
| 153 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { | 154 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { | 
| 154 | return YES; | 155 | return YES; | 
| 155 | } | 156 | } | 
| 156 | 157 | ||
| 157 | @end | 158 | @end | 
| 158 | 159 |