ViewController.m
4.57 KB
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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//
// ViewController.m
// publiDemo
//
// Created by winFan on 11/30/15.
// Copyright (c) 2015 winFan. All rights reserved.
//
#import "ViewController.h"
#import "PoolSdk/PoolSdk.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
[button1 setTitle:@"登陆" forState:UIControlStateNormal];
button1.frame = CGRectMake(50.0f, 100.0f, 50.0f, 40.0f);
button1.tag = 1;
[button1 addTarget:self action:@selector(toggleButton:) forControlEvents: UIControlEventTouchUpInside];
[self.view addSubview:button1];
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
[button2 setTitle:@"数据" forState:UIControlStateNormal];
button2.frame = CGRectMake(150.0f, 100.0f, 50.0f, 40.0f);
button2.tag = 2;
[button2 addTarget:self action:@selector(toggleButton:) forControlEvents: UIControlEventTouchUpInside];
[self.view addSubview:button2];
UIButton *button4 = [UIButton buttonWithType:UIButtonTypeCustom];
[button4 setTitle:@"充值" forState:UIControlStateNormal];
button4.frame = CGRectMake(150.0f, 50.0f, 50.0f, 40.0f);
button4.tag = 4;
[button4 addTarget:self action:@selector(toggleButton:) forControlEvents: UIControlEventTouchUpInside];
[self.view addSubview:button4];
UIButton *button6 = [UIButton buttonWithType:UIButtonTypeCustom];
[button6 setTitle:@"获取配置参数" forState:UIControlStateNormal];
button6.frame = CGRectMake(10.0f, 50.0f, 150.0f, 40.0f);
button6.tag = 6;
[button6 addTarget:self action:@selector(toggleButton:) forControlEvents: UIControlEventTouchUpInside];
[self.view addSubview:button6];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveSDKMessage:) name:poolSDK_Notification object:nil];
}
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[[PoolSdk shareSDK] viewDidAppear];
}
- (void) toggleButton: (UIButton *) button
{
// if (isOn = !isOn)
//
// {
int tag = (int)button.tag;
if (tag == 1) {
[[PoolSdk shareSDK] loginSDK];
}
else if (tag == 2)
{
NSLog(@"数据接口");
PoolReportInfo *reportInfo = [[PoolReportInfo alloc]init];
[reportInfo setReportType:@"ENTER"];
[reportInfo setServerId:@"9133"];
[reportInfo setPlayerId:@"pserverName"];
[[PoolSdk shareSDK] reportSDK:reportInfo];
}
else if (tag == 4)
{
PoolCreateOrderInfo *payInfo = [[PoolCreateOrderInfo alloc]init];
[payInfo setServerId:@"111"];
[payInfo setPostAmount:@"10"];
[payInfo setPlayerId:@"1231241234"];
[payInfo setTimestamp:@"1232134"];
[[PoolSdk shareSDK] payWithPaymentInfo:payInfo];
// [[YouaiSDKMgr getInstance] openPay:@"11" :@"你好" : nil : self];
}
else if(tag == 6){
PoolSdk *poolSdk = [PoolSdk shareSDK];
NSLog(@"channelId:%@parame1:%@parame2:%@custom:%@",[poolSdk getGameChannelId],[poolSdk getChannelParameter1],[poolSdk getChannelParameter2],[poolSdk getCustomValue]);
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)receiveSDKMessage:(NSNotification *)notification
{
[[PoolConfig getInstance] getValueByKey:@"gamechannelid"];
PoolSDKResult *result = [notification object];
if (result == nil ) {
return;
}
switch (result.notiType) {
case PoolSDKNotificationInitSDK:
{
NSLog(@"收到PoolSDKNotificationInitSDK");
}
break;
case PoolSDKNotificationLogin:
{
if (result.statusCode == POOLSDK_NO_ERROR) {
PoolLoginInfo *loginInfo = result.extendData;
NSLog(@"收到登陆信息public openid:%@", [loginInfo openId]);
NSLog(@"收到登陆信息public token:%@", [loginInfo sign]);
NSLog(@"收到登陆信息public timestamp:%@", [loginInfo timestamp]);
}else{
NSLog(@"%@",[result description]);
}
}
break;
case PoolSDKNotificationPay:
{
NSLog(@"收到登陆信息PoolSDKNotificationPay");
}
break;
default:
break;
}
}
@end