Blame view
ios/GameSDKDemo/letsgameDemo/LSGMainViewController.m
5.87 KB
23a302b86
![]() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
// // LSGMainViewController.m // letsgameDemo // // Created by zhy on 14-5-24. // // #import "LSGMainViewController.h" #import "LetsGameAPI.h" #import "VKBridge.h" @interface LSGMainViewController () @property (nonatomic, strong) UILabel *resultLabel; @property(nonatomic,strong) UIButton *vkActivityShareBtn; @property(nonatomic,copy) NSString *sessionKey; @end @implementation LSGMainViewController - (void)loadView { [super loadView]; NSLog(@"i come in"); self.view.backgroundColor = [UIColor whiteColor]; |
0605edc71
![]() |
29 |
// self.view.backgroundColor = [UIColor blackColor]; |
23a302b86
![]() |
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 |
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]; |
635b66127
![]() |
64 |
|
23a302b86
![]() |
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
} - (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 { |
9fb44a9bf
![]() |
84 85 |
[LetsGameAPI instance].appId = @"10022";//10047 [LetsGameAPI instance].appKey = @"93a27b0bd99bac3e68a440b48aa421ab";//eccd9f7dc92858b741132fda313130cf |
23a302b86
![]() |
86 |
[LetsGameAPI hiddenLogo:YES]; |
135cc0db4
![]() |
87 |
[LetsGameAPI disableFB:NO]; |
9fb44a9bf
![]() |
88 |
[LetsGameAPI disableGoogle:NO]; |
23a302b86
![]() |
89 90 91 92 93 94 95 96 97 98 99 |
NSLog(@"sdk version:%@",[[LetsGameAPI instance] version]); //启用vk登录 VKBridge *vkBridge = [[VKBridge alloc] initWithVKAppId:@"5029792"]; [LetsGameAPI instance].vkBridge = vkBridge; [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"; |
79f6c46ef
![]() |
100 |
}; |
23a302b86
![]() |
101 102 |
[[LetsGameAPI instance] showLoginView]; |
bc341763c
![]() |
103 |
|
23a302b86
![]() |
104 105 106 107 |
} - (void)onLogoutTest { |
e47bb8dbb
![]() |
108 109 |
[LetsGameAPI instance].appId = @"10056"; [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21"; |
23a302b86
![]() |
110 111 112 113 114 |
[[LetsGameAPI instance] logout]; } -(void)onPayTest{ |
0605edc71
![]() |
115 116 |
[LetsGameAPI instance].appId = @"10056";//10022 [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21";//93a27b0bd99bac3e68a440b48aa421ab |
23a302b86
![]() |
117 118 119 120 121 122 |
NSMutableDictionary *payInfo = [NSMutableDictionary dictionary]; [payInfo setValue:@"100" forKey:@"serverId"]; [payInfo setValue:@"10010" forKey:@"roleId"]; [payInfo setValue:@"1000" forKey:@"channelId"]; [payInfo setValue:@"10" forKey:@"amount"]; [payInfo setValue:@"ios demo" forKey:@"extraInfo"]; |
0605edc71
![]() |
123 124 |
[payInfo setValue:@"test" forKey:@"product"]; [payInfo setValue:@"76c17cc68ff9f7f40bd3d096ccc5600a" forKey:@"sessionKey"]; //self.sessionKey |
4c7cd90d2
![]() |
125 126 127 |
[[LetsGameAPI instance] pay:payInfo handleCallBack:^{ NSLog(@"第三方支付完成"); }]; |
23a302b86
![]() |
128 129 130 |
} -(void)onIapTest{ |
135cc0db4
![]() |
131 |
|
635b66127
![]() |
132 133 |
[LetsGameAPI instance].appId = @"10056"; [LetsGameAPI instance].appKey = @"b59c21a078fde074a6750e91ed19fb21"; |
23a302b86
![]() |
134 135 136 137 138 139 140 141 142 143 |
NSMutableDictionary *payInfo = [NSMutableDictionary dictionary]; [payInfo setValue:@"5001" forKey:@"serverId"]; [payInfo setValue:@"10010" forKey:@"roleId"]; [payInfo setValue:@"1000" forKey:@"channelId"]; [payInfo setValue:@"10" forKey:@"amount"]; [payInfo setValue:@"ios demo" forKey:@"extraInfo"]; [payInfo setValue:@"test.product.1" forKey:@"product"]; [[LetsGameAPI instance] iap:payInfo forUser:@"" handleCallback:^(NSString* orderId){ NSLog(@"IAP completed orderId of Gumptech:%@",orderId); }]; |
135cc0db4
![]() |
144 |
|
23a302b86
![]() |
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
} - (BOOL)shouldAutorotate { return YES; } -(UIInterfaceOrientationMask)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskAll; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } @end |