Blame view

ios/GameSDKDemo/letsgameDemo/LSGMainViewController.m 7.94 KB
23a302b86   alexYang   GameSDK 的iOS分支提交,...
1
2
3
4
5
6
7
8
9
10
  //
  //  LSGMainViewController.m
  //  letsgameDemo
  //
  //  Created by zhy on 14-5-24.
  //
  //
  
  #import "LSGMainViewController.h"
  #import "LetsGameAPI.h"
524f88220   alexYang   Activity 增加
11
  #import "LetsGameActivityAPI.h"
23a302b86   alexYang   GameSDK 的iOS分支提交,...
12
13
14
15
16
  
  
  @interface LSGMainViewController ()
  
  @property (nonatomic, strong) UILabel *resultLabel;
23a302b86   alexYang   GameSDK 的iOS分支提交,...
17
  @property(nonatomic,copy) NSString *sessionKey;
ac9cc1e15   alexYang   活动sdk增加活动类型参数
18
19
  
  @property(nonatomic, strong) UITextField *activityTextField;
23a302b86   alexYang   GameSDK 的iOS分支提交,...
20
21
22
23
24
25
26
  @end
  
  @implementation LSGMainViewController
  
  - (void)loadView {
      [super loadView];
      NSLog(@"i come in");
582a5a730   alexYang   1、界面UI更新 2、删除VK登录...
27
28
  //    self.view.backgroundColor = [UIColor whiteColor];
      self.view.backgroundColor = [UIColor blackColor];
23a302b86   alexYang   GameSDK 的iOS分支提交,...
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
      
      UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(110, 40, 100, 30)];
      btn.backgroundColor = [UIColor orangeColor];
      [btn setTitle:@"测试入口" forState:UIControlStateNormal];
      [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
      btn.titleLabel.font = [UIFont systemFontOfSize:15];
      [btn addTarget:self action:@selector(onClickTest) forControlEvents:UIControlEventTouchUpInside];
      [self.view addSubview:btn];
      
      
      
      UIButton *bindtn = [[UIButton alloc] initWithFrame:CGRectMake(110, 100, 100, 30)];
      bindtn.backgroundColor = [UIColor orangeColor];
      [bindtn setTitle:@"退出账号" forState:UIControlStateNormal];
      [bindtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
      bindtn.titleLabel.font = [UIFont systemFontOfSize:15];
      [bindtn addTarget:self action:@selector(onLogoutTest) forControlEvents:UIControlEventTouchUpInside];
      [self.view addSubview:bindtn];
      
      UIButton *payBtn = [[UIButton alloc] initWithFrame:CGRectMake(110, 160, 100, 30)];
      payBtn.backgroundColor = [UIColor orangeColor];
      [payBtn setTitle:@"支付" forState:UIControlStateNormal];
      [payBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
      payBtn.titleLabel.font = [UIFont systemFontOfSize:15];
      [payBtn addTarget:self action:@selector(onPayTest) forControlEvents:UIControlEventTouchUpInside];
      [self.view addSubview:payBtn];
      
      UIButton *iapBtn = [[UIButton alloc] initWithFrame:CGRectMake(110, 220, 100, 30)];
      iapBtn.backgroundColor = [UIColor orangeColor];
      [iapBtn setTitle:@"IAP" forState:UIControlStateNormal];
      [iapBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
      iapBtn.titleLabel.font = [UIFont systemFontOfSize:15];
      [iapBtn addTarget:self action:@selector(onIapTest) forControlEvents:UIControlEventTouchUpInside];
      [self.view addSubview:iapBtn];
524f88220   alexYang   Activity 增加
63
64
65
66
67
68
69
70
      
      UIButton *activityBtn = [[UIButton alloc] initWithFrame:CGRectMake(110, 320, 100, 30)];
      activityBtn.backgroundColor = [UIColor orangeColor];
      [activityBtn setTitle:@"Activity" forState:UIControlStateNormal];
      [activityBtn setTintColor:[UIColor whiteColor]];
      activityBtn.titleLabel.font = [UIFont systemFontOfSize:15];
      [activityBtn addTarget:self action:@selector(onActivity) forControlEvents:UIControlEventTouchUpInside];
      [self.view addSubview:activityBtn];
ac9cc1e15   alexYang   活动sdk增加活动类型参数
71
72
73
74
75
76
77
78
      
      UITextField *activityField = [[UITextField alloc] initWithFrame:CGRectMake(220, 320, 100, 30)];
      activityField.placeholder = @"活动类型";
      activityField.backgroundColor = [UIColor whiteColor];
      self.activityTextField = activityField;
      [self.view addSubview:self.activityTextField];
      
      
635b66127   alexYang   1、自动登录部分修改,将自动登录部...
79

23a302b86   alexYang   GameSDK 的iOS分支提交,...
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
  }
  
  - (UILabel *)resultLabel {
      if (!_resultLabel) {
          _resultLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.view.frame) - 90, self.view.frame.size.width, 60)];
          _resultLabel.backgroundColor = [UIColor clearColor];
          _resultLabel.textAlignment = NSTextAlignmentCenter;
          _resultLabel.textColor = [UIColor redColor];
          _resultLabel.font = [UIFont systemFontOfSize:15];
          _resultLabel.numberOfLines = 4;
          _resultLabel.lineBreakMode = NSLineBreakByWordWrapping;
          [self.view addSubview:_resultLabel];
      }
      
      return _resultLabel;
  }
  
  
  - (void)onClickTest {
050bf6331   alexYang   1、新增sdk登录初始化接口 2、...
99
100
      [LetsGameAPI instance].appId = @"100";
      [LetsGameAPI instance].appKey = @"f899139df5e1059396431415e770c6dd";
d7e540e1e   alexYang   1、关闭页面接口增加2、关于游客登...
101
      [LetsGameAPI instance].channelId = @"1000";
23a302b86   alexYang   GameSDK 的iOS分支提交,...
102
      [LetsGameAPI hiddenLogo:YES];
23a302b86   alexYang   GameSDK 的iOS分支提交,...
103
      NSLog(@"sdk version:%@",[[LetsGameAPI instance] version]);
050bf6331   alexYang   1、新增sdk登录初始化接口 2、...
104
105
106
107
      //sdk login 初始化
      [[LetsGameAPI instance] SDKLoginInitofResponse:^(BOOL result) {
          if (result) {
              NSLog(@"初始化成功");
d2548f7e2   alexYang   韩文修改和游客登录并列到第三方登录同级
108
109
  //                [LetsGameAPI disableFB:YES];
  //                [LetsGameAPI disableGoogle:YES];
582a5a730   alexYang   1、界面UI更新 2、删除VK登录...
110
  //                [LetsGameAPI disableLine:YES];
050bf6331   alexYang   1、新增sdk登录初始化接口 2、...
111
112
113
114
115
116
117
118
119
120
121
122
123
              
              [LetsGameAPI instance].succBlock = ^(NSString *userId, NSString *sessionKey, LSGAccountType type) {
                  self.sessionKey = sessionKey;
                  self.resultLabel.text = [NSString stringWithFormat:@"login succ: userId = %@, sessionKey = %@, accountType = %ld", userId, sessionKey, type];
              };
              [LetsGameAPI instance].dismissBlock = ^() {
                  //登录失败操作
                  self.resultLabel.text = @"dismiss without login";
              };
              
              [[LetsGameAPI instance] showLoginView];
          }else{
              NSLog(@"初始化失败");
9c951e2e3   alexYang   wechat登录删除,增加德语适配
124
              self.resultLabel.text = @"初始化失败";
050bf6331   alexYang   1、新增sdk登录初始化接口 2、...
125
126
          }
      }];
23a302b86   alexYang   GameSDK 的iOS分支提交,...
127
128
129
130
  }
  
  
  - (void)onLogoutTest {
e47bb8dbb   alexYang   v3.3.15 facebook自...
131
132
      [LetsGameAPI instance].appId = @"10056";
      [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21";
23a302b86   alexYang   GameSDK 的iOS分支提交,...
133
134
135
136
137
      [[LetsGameAPI instance] logout];
    
  }
  
  -(void)onPayTest{
524f88220   alexYang   Activity 增加
138
139
      [LetsGameAPI instance].appId = @"10103";//@"10056";//10022
      [LetsGameAPI instance].appKey = @"f53eb4122d5e2ce81a12093f8f9ce922";//@"b59c21a078fde074a6750e91ed19fb21";//93a27b0bd99bac3e68a440b48aa421ab
23a302b86   alexYang   GameSDK 的iOS分支提交,...
140
      NSMutableDictionary *payInfo = [NSMutableDictionary dictionary];
524f88220   alexYang   Activity 增加
141
142
143
      [payInfo setValue:@"s1" forKey:@"serverId"];
      [payInfo setValue:@"556553" forKey:@"roleId"];
      [payInfo setValue:@"1002" forKey:@"channelId"];
23a302b86   alexYang   GameSDK 的iOS分支提交,...
144
145
      [payInfo setValue:@"10" forKey:@"amount"];
      [payInfo setValue:@"ios demo" forKey:@"extraInfo"];
524f88220   alexYang   Activity 增加
146
147
      [payInfo setValue:@"wa2" forKey:@"product"];
      [payInfo setValue:@"78b83666bd77c1e4c95442140672254d" forKey:@"sessionKey"]; //self.sessionKey
d7e540e1e   alexYang   1、关闭页面接口增加2、关于游客登...
148
149
150
  //    [[LetsGameAPI instance] pay:payInfo handleCallBack:^{
  //        NSLog(@"第三方支付完成");
  //    }];
f8353174d   alexYang   1、第三方支付中含有pay的字段修...
151
      [[LetsGameAPI instance] pWeb:payInfo handleCallBack:^{
4c7cd90d2   alexYang   增加第三方支付完成回调,版本v3....
152
153
          NSLog(@"第三方支付完成");
      }];
23a302b86   alexYang   GameSDK 的iOS分支提交,...
154
155
156
  }
  
  -(void)onIapTest{
54734cd48   alexYang   登录日志添加,第三方支付文档修改
157
158
159
  
      [LetsGameAPI instance].appId = @"10056";
      [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21";
23a302b86   alexYang   GameSDK 的iOS分支提交,...
160
      NSMutableDictionary *payInfo = [NSMutableDictionary dictionary];
54734cd48   alexYang   登录日志添加,第三方支付文档修改
161
162
      [payInfo setValue:@"5001" forKey:@"serverId"];
      [payInfo setValue:@"10010" forKey:@"roleId"];
23a302b86   alexYang   GameSDK 的iOS分支提交,...
163
      [payInfo setValue:@"1000" forKey:@"channelId"];
54734cd48   alexYang   登录日志添加,第三方支付文档修改
164
165
166
      [payInfo setValue:@"10" forKey:@"amount"];
      [payInfo setValue:@"ios demo" forKey:@"extraInfo"];
      [payInfo setValue:@"test.product.1" forKey:@"product"];
6e191f658   alexYang   iap 支付回调增加失败回调
167
168
      [[LetsGameAPI instance] iap:payInfo forUser:@"" succCallback:^(NSString *orderId) {
          //注意测试仅仅是通知客户端成功,但是还需要向服务器请求验证是否成功,以服务端验证为准
23a302b86   alexYang   GameSDK 的iOS分支提交,...
169
          NSLog(@"IAP completed orderId of Gumptech:%@",orderId);
6e191f658   alexYang   iap 支付回调增加失败回调
170
171
      } failCallback:^(NSString *orderId) {
          NSLog(@"IAP file orderId of Gumptech:%@",orderId);
23a302b86   alexYang   GameSDK 的iOS分支提交,...
172
173
      }];
  }
524f88220   alexYang   Activity 增加
174
175
176
  -(void)onActivity{
      
      [[LetsGameActivityAPI instance] decideIsDebug:1];
524f88220   alexYang   Activity 增加
177
178
179
180
181
182
183
184
185
      NSMutableDictionary *activityInfo = [NSMutableDictionary dictionary];
      [activityInfo setValue:@"100" forKey:@"appId"];
      [activityInfo setValue:@"f899139df5e1059396431415e770c6dd" forKey:@"appKey"];
      [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"];
ac9cc1e15   alexYang   活动sdk增加活动类型参数
186
      [activityInfo setValue:self.activityTextField.text forKey:@"campaignType"];
524f88220   alexYang   Activity 增加
187
188
189
190
      [[LetsGameActivityAPI instance] GameActivityWithParaDictory:activityInfo handleCallBackL:^{
          NSLog(@"activity finish!");
      }];
  }
23a302b86   alexYang   GameSDK 的iOS分支提交,...
191

23a302b86   alexYang   GameSDK 的iOS分支提交,...
192
193
  
  @end