Blame view

IOSDocument.md 6.79 KB
d7a5aae31   alexYang   IAP支付方法修改,第三方支付不传...
1
2
3
4
  # Gump IOS SDK使用文档
  
  
  接入手册        
58aa87d07   alexYang   账号联动和iap支付中重复充值中的问题
5
6
7
  登陆sdk:GumpLoginSDK.framework v1.0.11
  支付sdk: GameSDK.framework v4.0.7
  2019年5月31日    
d7a5aae31   alexYang   IAP支付方法修改,第三方支付不传...
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
          
  ## 概述  
  #### 本SDK提供Game Center登陆 和 游客登陆两种账号登录,iap支付和第三方支付两种支付功能,活动SDK(大转盘等)。
  
  ## 接入步骤
  ### 1、添加Framework和资源文件  
  + 以下为必须添加的framework以及资源bundle:  
  MobileCoreServices.framework、SystemConfiguration.framework、libz.dylib、CFNetwork.framework、GumpLoginSDK.framework、GameSDK.framework、GameActivitySDK.framework、StoreKit.framework、GameSDKResources.bundle
  
  ### 2、引入头文件,设置build setting    
  因sdk内使用了category,需要设置other linker flag为 -ObjC
   
  
  ### 3、增加必要配置  
  1)在application delegate中, 在application:openURL:sourceApplication:annotation:添加返回:
  
      return [[LetsGameAPI instance] handleOpenURL:url sourceApplication:sourceApplication];
      
  2) 在工程的Targets->Capablities->Game Center 打开
    
   
  ### 4、在工程里添加SDK登录代码  
  添加GumpLoginSDK.framework
      
      
  	[[GPGameLoginSDK instance] GPGameLoginWithViewController:self appID:@"100" channelId:@"10002"];
      [GPGameLoginSDK instance].succBlock = ^(NSNumber *userId, ACCOUNTTYPE type) {
          self.resultLabel.text = [NSString stringWithFormat:@"userId: %@, accountType: %ld", userId, (long)type];
      };
      [GPGameLoginSDK instance].failBlock = ^{
          self.resultLabel.text = @"login error";
      };
      
  
  ### 5、第三方支付    
      [LetsGameAPI instance].appId = @"10022";
      NSMutableDictionary *payInfo = [NSMutableDictionary dictionary];
      [payInfo setValue:@"5001" forKey:@"serverId"];//服务器id,必传参数
      [payInfo setValue:@"10010" forKey:@"roleId"];//用户角色id
      [payInfo setValue:@"1595907" forKey:@"userId"];//用户ID userId
      [payInfo setValue:@"1000" forKey:@"channelId"];//渠道id
      [payInfo setValue:@"10" forKey:@"amount"];//金额
      [payInfo setValue:@"ios demo" forKey:@"extraInfo"];//外部订单信息
      [payInfo setValue:@"test1" forKey:@"product"];//商品ID
      [[LetsGameAPI instance] pWeb:payInfo handleCallBack:^{
      	//第三方支付完成时的回调(包括支付成功和支付失败,除了支付过程中取消的),取消的不会有回调
          NSLog(@"第三方支付完成");
      }]];
      
  ### 6、IAP支付
  若要使用apple IAP支付,需要在AppDelegate的application: didFinishLaunchingWithOptions:方法内注册iap observer,使用如下方法   
  
      [[LetsGameAPI instance] registeIapObserver];  
  具体调用iap支付的方法如下:   
      
      [LetsGameAPI instance].appId = @"100";
      NSMutableDictionary *payInfo = [NSMutableDictionary dictionary];
      [payInfo setValue:@"5001" forKey:@"serverId"];//当前用户所在的服务器Id
      [payInfo setValue:@"10010" forKey:@"roleId"];//当前用户的角色id
      [payInfo setValue:@"1595907" forKey:@"userId"];//用户ID userId
      [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 succCallback:^(NSString *orderId) {
          //此处的回调表明支付已经完成,但此时支付不一定成功,需要服务端验证支付结果
          //orderId为gump生成的订单号,此订单号可以在gump server查询此笔支付是否成功
          NSLog(@"IAP completed orderId of Gumptech:%@",orderId);
      } failCallback:^(NSString *orderId) {
      	 //支付失败
          NSLog(@"IAP file orderId of Gumptech:%@",orderId);
      }];
      
      
  ### 7、第三方支付版本
  第三方支付,分成两个版本:没有gump币和有gump币,不设置时默认为不带gump币版本,如果使用带gump币的版本如下设置:
  	
  	需要在 application:didFinishLaunchingWithOptions方法中添加:
  	
  	[[LetsGameAPI instance] decideWebToVersion:1]
  
  ### 8、第三方支付横竖屏设置
  添加GameSDK.framework
      首先设置支付SDK默认是横屏,在General->Deployment Info->Device Orientain下,只选择Landscape Left 和 Landscape Right,SDK的界面默认是横屏。
      其次如果想使用竖屏的模式,需要在General->Deployment Info->Device Orientain下,只选择Portrait模式,并且需要在AppDelegate中的方法:
      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;靠前的位置添加代码设置:
      
      [LetsGameAPI DeviceOrientationIsHorizontal:NO];
      
  ### 9、活动添加
  添加GameActivitySDK.framework
  设置:设置xxxx.plist
  只支持HTTP的方式,需要将相应的项目的xxx.plist添加Information Property List->App Transport Security Settings -> Allow Arbitrary Loads设置为YES
  
  工程中添加SDK登录代码:
  
      NSMutableDictionary *activityInfo = [NSMutableDictionary dictionary];
      [activityInfo setValue:@"100" forKey:@"appId"];
      [activityInfo setValue:@"123456" forKey:@"userId"];
      [activityInfo setValue:@"111" forKey:@"serverId"];
      [activityInfo setValue:@"aaa" forKey:@"serverName"];
      [activityInfo setValue:@"222" forKey:@"roleId"];
      [activityInfo setValue:@"ccc" forKey:@"roleName"];
      [activityInfo setValue:@"888" forKey:@"diamond"];
      //活动关闭的回调
      [[LetsGameActivityAPI instance] GameActivityWithParaDictory:activityInfo handleCallBackL:^{
          NSLog(@"activity finish!");
      }];
      
58aa87d07   alexYang   账号联动和iap支付中重复充值中的问题
117
  ### 10、账号联动
d7a5aae31   alexYang   IAP支付方法修改,第三方支付不传...
118
  需要提供按钮绑定,点击事件调用下面方法。
58aa87d07   alexYang   账号联动和iap支付中重复充值中的问题
119
120
  此功能涉及账号的绑定和切换,回调只有在切换成功之后才会出现,其他情况的回调都是失败的回调。
  工程中添加SDK账号联动代码:
d7a5aae31   alexYang   IAP支付方法修改,第三方支付不传...
121

58aa87d07   alexYang   账号联动和iap支付中重复充值中的问题
122
123
124
125
126
       NSMutableDictionary *linkParaDic = [NSMutableDictionary dictionary];
      [linkParaDic setObject:@"10022" forKey:@"appId"];
      [linkParaDic setObject:self.userId forKey:@"userId"];
      //仅在切换账号成功的时候有返回值
      [[GPGameLoginSDK instance] GPGameAccountLinkViewController:self InfoDic:linkParaDic callBack:^(NSNumber *userId, ACCOUNTENTERTYPE type) {
d7a5aae31   alexYang   IAP支付方法修改,第三方支付不传...
127
          self.resultLabel.text = [NSString stringWithFormat:@"userId: %@, accountType: %ld", userId, (long)type];
d7a5aae31   alexYang   IAP支付方法修改,第三方支付不传...
128
      }];
d7a5aae31   alexYang   IAP支付方法修改,第三方支付不传...
129

58aa87d07   alexYang   账号联动和iap支付中重复充值中的问题
130
  ### 11、切换系统账号
d7a5aae31   alexYang   IAP支付方法修改,第三方支付不传...
131
132
133
134
135
136
137
138
  需要提供按钮切换系统账号,点击事件调用下面方法。
  需要用户自己去往Game Center切换账号,之后再次登陆游戏才能实现账号切换。
  工程中添加SDK切换系统账号代码:
  
      [[GPGameLoginSDK instance] GPSwitchGameCenterWithViewController:self switchCallBack:^{
          self.resultLabel.text = @"Login Game Center";
      }];