Blame view
doc/IOSDocument.md
4.77 KB
|
d6a208e3c
|
1 2 3 4 |
# Gump IOS SDK使用文档 接入手册 |
|
f1900b258
|
5 6 |
V 3.3.8 2016年07月04日 |
|
d6a208e3c
|
7 |
|
|
bd0fbf81f
|
8 9 |
## 概述 #### 本SDK提供gump账号,fb账号,vk账号三种账号登录,iap支付和第三方支付两种支付功能,其中gump账号登录和fb账号登录功能为必须接入,支付可根据需要选择性接入。 |
|
d6a208e3c
|
10 |
|
|
bd0fbf81f
|
11 12 13 |
## 接入步骤 ### 1、添加Framework和资源文件 + 以下为必须添加的framework以及资源bundle: |
|
68b98edcd
|
14 |
MobileCoreServices.framework、SystemConfiguration.framework、libz.dylib、CFNetwork.framework、GameSDK.framework、StoreKit.framework、GameSDKResources.bundle、libsqlite3.tbd |
|
bd0fbf81f
|
15 16 |
+ 以下为可选,若接入vk登录则需要添加以下framework和bundle,其中VKSdk.framework和VKSDKResources.bundle请自行从vk.com下载,使用1.3版本 VKSdk.framework、VKBridge.framework、VKSDKResources.bundle |
|
d6a208e3c
|
17 |
|
|
d6a208e3c
|
18 |
|
|
bd0fbf81f
|
19 20 21 22 |
### 2、引入头文件,设置build setting 需要使用头文件有LetsGameAPI.h和VKBridge.h,其中VKBridge.h为接入vk时使用,不接入vk可忽略。 因sdk内使用了category,需要设置other linker flag为 -ObjC |
|
d6a208e3c
|
23 |
|
|
bd0fbf81f
|
24 25 |
### 3、增加必要配置 1)在application delegate中, 在application:openURL:sourceApplication:annotation:添加返回: |
|
d6a208e3c
|
26 |
|
|
ca2f3a935
|
27 |
return [[LetsGameAPI instance] handleOpenURL:url sourceApplication:sourceApplication]; |
|
bd0fbf81f
|
28 29 |
2)配置URL-schema(vk专用,不接入vk可忽略) |
|
ca2f3a935
|
30 |
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. |
|
b0a82b44b
|
31 |
 |
|
ca2f3a935
|
32 |
Xcode 4: Open your Info.plist then add a new row URL Types. Set the URL identifier to vk+APP_ID |
|
b0a82b44b
|
33 |
 |
|
bd0fbf81f
|
34 |
### 4、在工程里添加SDK登录代码 |
|
d6a208e3c
|
35 36 37 |
[LetsGameAPI instance].appId = @"100"; // 设置appId [LetsGameAPI instance].appKey = @"100"; // 设置appKey |
|
bd0fbf81f
|
38 39 40 41 |
//启用vk的代码,需要填入vk appId,若不接入vk,可以忽略 //VKBridge *vkBridge = [[VKBridge alloc] initWithVKAppId:@"5029792"]; //[LetsGameAPI instance].vkBridge = vkBridge; |
|
cfe987262
|
42 |
|
|
cb177c739
|
43 |
//隐藏fb登录 |
|
f175cbeae
|
44 |
[LetsGameAPI disableFB:YES]; |
|
cb177c739
|
45 |
|
|
cfe987262
|
46 47 |
//隐藏gumptech的logo [LetsGameAPI hiddenLogo:YES]; |
|
bd0fbf81f
|
48 |
|
|
d6a208e3c
|
49 50 51 52 53 54 55 56 57 58 59 |
[[LetsGameAPI instance] showLoginView]; // 弹出登录页面
// 登录成功回调
[LetsGameAPI instance].succBlock = ^(NSString *userId, NSString *sessionKey, LSGAccountType type) {
NSLog(@"%@", [NSString stringWithFormat:@"login succ: userId = %@, sessionKey = %@, accountType = %d", userId, sessionKey, type]);
};
// 登录失败回调
[LetsGameAPI instance].dismissBlock = ^() {
NSLog(@"dismiss without login");
};
|
|
bd0fbf81f
|
60 |
### 5、第三方支付 |
|
d392082b9
|
61 62 63 |
[LetsGameAPI instance].appId = @"10022";
[LetsGameAPI instance].appKey = @"f899139df5e1059396431415e770c6dd";
NSMutableDictionary *payInfo = [NSMutableDictionary dictionary];
|
|
1686b46fd
|
64 |
[payInfo setValue:@"5001" forKey:@"serverId"];//服务器id,必传参数 |
|
d392082b9
|
65 66 67 68 |
[payInfo setValue:@"1000" forKey:@"channelId"];//渠道id
[payInfo setValue:@"10" forKey:@"amount"];//金额
[payInfo setValue:@"ios demo" forKey:@"extraInfo"];//外部订单信息
[payInfo setValue:@"元宝" forKey:@"product"];//物品信息
|
|
1b0de7714
|
69 70 |
[[LetsGameAPI instance] pay:payInfo];
|
|
bd0fbf81f
|
71 |
### 6、IAP支付 |
|
414106be1
|
72 |
若要使用apple IAP支付,需要在AppDelegate的application: didFinishLaunchingWithOptions:方法内注册iap observer,使用如下方法 |
|
1b0de7714
|
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
[[LetsGameAPI instance] registeIapObserver];
具体调用iap支付的方法如下:
[LetsGameAPI instance].appId = @"10022";
[LetsGameAPI instance].appKey = @"93a27b0bd99bac3e68a440b48aa421ab";
NSMutableDictionary *payInfo = [NSMutableDictionary dictionary];
[payInfo setValue:@"5001" forKey:@"serverId"];//当前用户所在的服务器Id
[payInfo setValue:@"10010" forKey:@"roleId"];//当前用户的角色id
[payInfo setValue:@"1000" forKey:@"channelId"];//渠道id,用于统计
[payInfo setValue:@"10" forKey:@"amount"];//对应支付项的支付金额,实际支付金额以itunes配置为准
[payInfo setValue:@"ios demo" forKey:@"extraInfo"];//扩展信息,可以游戏自定义,建议传自有订单号
[payInfo setValue:@"test.product.1" forKey:@"product"];//itunes 后台配置的对应支付项的productId
[[LetsGameAPI instance] iap:payInfo forUser:@"" handleCallback:^(NSString* orderId){
//此处的回调表明支付已经完成,但此时支付不一定成功,需要服务端验证支付结果
//orderId为gump生成的订单号,此订单号可以在gump server查询此笔支付是否成功
NSLog(@"iap completed orderId of gumptech:%@",orderId);
|
|
68b98edcd
|
90 91 92 93 94 |
}];
### 7、SDK版本测试设置
若想使用SDK的debug版本,需要在AppDelegate的application: didFinishLaunchingWithOptions:中设置:
[[LetsGameAPI instance] decideIsDebug:1];
不设置或者设置为0时,默认使用release版本
|