Commit bc341763c8e1d807309c7358da01e9d25673ffc4

Authored by alexYang
1 parent f579320ff0
Exists in master

tag 修改

Showing 2 changed files with 1 additions and 0 deletions Inline Diff

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 = @"10022";//10047 85 [LetsGameAPI instance].appId = @"10022";//10047
86 [LetsGameAPI instance].appKey = @"93a27b0bd99bac3e68a440b48aa421ab";//eccd9f7dc92858b741132fda313130cf 86 [LetsGameAPI instance].appKey = @"93a27b0bd99bac3e68a440b48aa421ab";//eccd9f7dc92858b741132fda313130cf
87 [LetsGameAPI hiddenLogo:YES]; 87 [LetsGameAPI hiddenLogo:YES];
88 [LetsGameAPI disableFB:NO]; 88 [LetsGameAPI disableFB:NO];
89 [LetsGameAPI disableGoogle:NO]; 89 [LetsGameAPI disableGoogle:NO];
90 NSLog(@"sdk version:%@",[[LetsGameAPI instance] version]); 90 NSLog(@"sdk version:%@",[[LetsGameAPI instance] version]);
91 //启用vk登录 91 //启用vk登录
92 VKBridge *vkBridge = [[VKBridge alloc] initWithVKAppId:@"5029792"]; 92 VKBridge *vkBridge = [[VKBridge alloc] initWithVKAppId:@"5029792"];
93 [LetsGameAPI instance].vkBridge = vkBridge; 93 [LetsGameAPI instance].vkBridge = vkBridge;
94 94
95 [LetsGameAPI instance].succBlock = ^(NSString *userId, NSString *sessionKey, LSGAccountType type) { 95 [LetsGameAPI instance].succBlock = ^(NSString *userId, NSString *sessionKey, LSGAccountType type) {
96 self.sessionKey = sessionKey; 96 self.sessionKey = sessionKey;
97 self.resultLabel.text = [NSString stringWithFormat:@"login succ: userId = %@, sessionKey = %@, accountType = %ld", userId, sessionKey, type]; 97 self.resultLabel.text = [NSString stringWithFormat:@"login succ: userId = %@, sessionKey = %@, accountType = %ld", userId, sessionKey, type];
98 }; 98 };
99 [LetsGameAPI instance].dismissBlock = ^() { 99 [LetsGameAPI instance].dismissBlock = ^() {
100 self.resultLabel.text = @"dismiss without login"; 100 self.resultLabel.text = @"dismiss without login";
101 }; 101 };
102 102
103 [[LetsGameAPI instance] showLoginView]; 103 [[LetsGameAPI instance] showLoginView];
104
104 } 105 }
105 106
106 107
107 - (void)onLogoutTest { 108 - (void)onLogoutTest {
108 [LetsGameAPI instance].appId = @"10056"; 109 [LetsGameAPI instance].appId = @"10056";
109 [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21"; 110 [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21";
110 [[LetsGameAPI instance] logout]; 111 [[LetsGameAPI instance] logout];
111 112
112 } 113 }
113 114
114 -(void)onPayTest{ 115 -(void)onPayTest{
115 [LetsGameAPI instance].appId = @"10056";//10022 116 [LetsGameAPI instance].appId = @"10056";//10022
116 [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21";//93a27b0bd99bac3e68a440b48aa421ab 117 [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21";//93a27b0bd99bac3e68a440b48aa421ab
117 NSMutableDictionary *payInfo = [NSMutableDictionary dictionary]; 118 NSMutableDictionary *payInfo = [NSMutableDictionary dictionary];
118 [payInfo setValue:@"100" forKey:@"serverId"]; 119 [payInfo setValue:@"100" forKey:@"serverId"];
119 [payInfo setValue:@"10010" forKey:@"roleId"]; 120 [payInfo setValue:@"10010" forKey:@"roleId"];
120 [payInfo setValue:@"1000" forKey:@"channelId"]; 121 [payInfo setValue:@"1000" forKey:@"channelId"];
121 [payInfo setValue:@"10" forKey:@"amount"]; 122 [payInfo setValue:@"10" forKey:@"amount"];
122 [payInfo setValue:@"ios demo" forKey:@"extraInfo"]; 123 [payInfo setValue:@"ios demo" forKey:@"extraInfo"];
123 [payInfo setValue:@"test" forKey:@"product"]; 124 [payInfo setValue:@"test" forKey:@"product"];
124 [payInfo setValue:@"76c17cc68ff9f7f40bd3d096ccc5600a" forKey:@"sessionKey"]; //self.sessionKey 125 [payInfo setValue:@"76c17cc68ff9f7f40bd3d096ccc5600a" forKey:@"sessionKey"]; //self.sessionKey
125 [[LetsGameAPI instance] pay:payInfo handleCallBack:^{ 126 [[LetsGameAPI instance] pay:payInfo handleCallBack:^{
126 NSLog(@"第三方支付完成"); 127 NSLog(@"第三方支付完成");
127 }]; 128 }];
128 } 129 }
129 130
130 -(void)onIapTest{ 131 -(void)onIapTest{
131 132
132 [LetsGameAPI instance].appId = @"10056"; 133 [LetsGameAPI instance].appId = @"10056";
133 [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21"; 134 [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21";
134 NSMutableDictionary *payInfo = [NSMutableDictionary dictionary]; 135 NSMutableDictionary *payInfo = [NSMutableDictionary dictionary];
135 [payInfo setValue:@"5001" forKey:@"serverId"]; 136 [payInfo setValue:@"5001" forKey:@"serverId"];
136 [payInfo setValue:@"10010" forKey:@"roleId"]; 137 [payInfo setValue:@"10010" forKey:@"roleId"];
137 [payInfo setValue:@"1000" forKey:@"channelId"]; 138 [payInfo setValue:@"1000" forKey:@"channelId"];
138 [payInfo setValue:@"10" forKey:@"amount"]; 139 [payInfo setValue:@"10" forKey:@"amount"];
139 [payInfo setValue:@"ios demo" forKey:@"extraInfo"]; 140 [payInfo setValue:@"ios demo" forKey:@"extraInfo"];
140 [payInfo setValue:@"test.product.1" forKey:@"product"]; 141 [payInfo setValue:@"test.product.1" forKey:@"product"];
141 [[LetsGameAPI instance] iap:payInfo forUser:@"" handleCallback:^(NSString* orderId){ 142 [[LetsGameAPI instance] iap:payInfo forUser:@"" handleCallback:^(NSString* orderId){
142 NSLog(@"IAP completed orderId of Gumptech:%@",orderId); 143 NSLog(@"IAP completed orderId of Gumptech:%@",orderId);
143 }]; 144 }];
144 145
145 } 146 }
146 147
147 148
148 - (BOOL)shouldAutorotate { 149 - (BOOL)shouldAutorotate {
149 return YES; 150 return YES;
150 } 151 }
151 152
152 -(UIInterfaceOrientationMask)supportedInterfaceOrientations{ 153 -(UIInterfaceOrientationMask)supportedInterfaceOrientations{
153 return UIInterfaceOrientationMaskAll; 154 return UIInterfaceOrientationMaskAll;
154 } 155 }
155 156
156 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 157 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
157 return YES; 158 return YES;
158 } 159 }
159 160
160 @end 161 @end
161 162