Blame view

doc/IOSDocument.md 3.08 KB
d6a208e3c   赵康   增加ios接入文档
1
2
3
4
5
  # Gump IOS SDK使用文档
  
  
  接入手册        
  V       
1b0de7714   赵康   增加iap支付
6
  2015年08月07日    
d6a208e3c   赵康   增加ios接入文档
7
8
9
10
          
  
  
  ## 1、添加动态库  
1b0de7714   赵康   增加iap支付
11
  在工程里添加MobileCoreServices.framework、SystemConfiguration.framework、libz.dylib、CFNetwork.framework、libletsgame.a、StoreKit.framework  
d6a208e3c   赵康   增加ios接入文档
12
13
14
15
16
17
18
19
  
  
  ## 2、设置头文件搜索路径  
  头文件只有LetsGameAPI.h和LSGAccount.h两个文件,引入头文件,并设置搜索路径。  
  
  
  ## 3、添加资源文件  
  在工程里添加letsgame.bundle资源文件,里面包含图片及相关语言包  
d392082b9   赵康   增加支付
20
  ## 4、在工程里添加SDK登录代码  
d6a208e3c   赵康   增加ios接入文档
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  
  	[LetsGameAPI instance].appId = @"100"; // 设置appId
  	[LetsGameAPI instance].appKey = @"100"; // 设置appKey
      
  	[[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");
  	};
1b0de7714   赵康   增加iap支付
36
  ## 5、第三方支付    
d392082b9   赵康   增加支付
37
38
39
      [LetsGameAPI instance].appId = @"10022";
      [LetsGameAPI instance].appKey = @"f899139df5e1059396431415e770c6dd";
      NSMutableDictionary *payInfo = [NSMutableDictionary dictionary];
1686b46fd   赵康   修改注释
40
      [payInfo setValue:@"5001" forKey:@"serverId"];//服务器id,必传参数
d392082b9   赵康   增加支付
41
42
43
44
      [payInfo setValue:@"1000" forKey:@"channelId"];//渠道id
      [payInfo setValue:@"10" forKey:@"amount"];//金额
      [payInfo setValue:@"ios demo" forKey:@"extraInfo"];//外部订单信息
      [payInfo setValue:@"元宝" forKey:@"product"];//物品信息
1b0de7714   赵康   增加iap支付
45
46
47
      [[LetsGameAPI instance] pay:payInfo];
      
  ## 6、IAP支付
414106be1   赵康   修改oc方法
48
  若要使用apple IAP支付,需要在AppDelegate的application: didFinishLaunchingWithOptions:方法内注册iap observer,使用如下方法   
1b0de7714   赵康   增加iap支付
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  
      [[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);
      }];