MainViewController.m
3.71 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
//
// MainViewController.m
// Demo_qiyu
//
// Created by 许 on 17/6/7.
// Copyright © 2017年 winFan. All rights reserved.
//
#import "MainViewController.h"
#import "PoolSdk.h"
@interface MainViewController ()
@end
@implementation MainViewController
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveSDKMessage:) name:poolSDK_Notification object:nil];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
//[[PoolSdk shareSDK] viewDidAppear];
}
- (void)receiveSDKMessage:(NSNotification *)notification
{
PoolSDKResult *result = [notification object];
if (result) {
NSLog(@"notiType:%d",result.notiType);
switch (result.notiType) {
case PoolSDKNotificationInitSDK:
{
NSLog(@"sdk初始化成功");
}
break;
case PoolSDKNotificationLogin:
{
NSLog(@"result state:%d",result.statusCode);
if (result.statusCode == POOLSDK_NO_ERROR) {
PoolLoginInfo *loginInfo = (PoolLoginInfo*)result.extendData;
NSLog(@"收到登陆信息public openid:%@", [loginInfo openId]);
NSLog(@"收到登陆信息public token:%@", [loginInfo sign]);
NSLog(@"收到登陆信息public timestamp:%@", [loginInfo timestamp]);
NSLog(@"userType:%@",[loginInfo userType]);
}else{
NSLog(@"%@",[result description]);
}
}
break;
case PoolSDKNotificationLogout:
{
NSLog(@"sdk注销成功,游戏处理");
}
break;
default:
break;
}
}
}
- (IBAction)actionInit:(id)sender {
[[PoolSdk shareSDK]initSDK:self];
}
- (IBAction)actionLogin:(id)sender {
[[PoolSdk shareSDK] loginSDK];
}
- (IBAction)actionPay:(id)sender {
PoolCreateOrderInfo *payInfo = [[PoolCreateOrderInfo alloc]init];
[payInfo setServerId:@"111"];
[payInfo setPlayerName:@"roleName"];
[payInfo setPlayerLevel:@"10"];
[payInfo setPostAmount:@"6"];
[payInfo setProductId:@"com.fytx.6"];
[payInfo setPlayerId:@"1231241234"];
[payInfo setTimestamp:@"1232134"];
[payInfo setExchange:@"10"];
[payInfo setCustom:@"custom"];
NSLog(@"start pay");
[[PoolSdk shareSDK] payWithPaymentInfo:payInfo];
}
/**
serverid
servername
roleid
rolename
rolelevel
*/
- (IBAction)actionSubmitRoleData:(id)sender {
NSLog(@"数据接口");
PoolReportInfo *reportInfo = [[PoolReportInfo alloc]init];
[reportInfo setReportType:REPORT_ENTER];
//[reportInfo setReportType:REPORT_CREATEROLE];
//[reportInfo setReportType:REPORT_ROLEUPGRADE]
[reportInfo setServerId:@"9133"];
[reportInfo setServerName:@"serverName"];
[reportInfo setPlayerId:@"123456"];
[reportInfo setPlayerName:@"playName"];
[reportInfo setPlayerLevel:@"100"];
[[PoolSdk shareSDK] reportSDK:reportInfo];
}
- (IBAction)actionLogout:(id)sender {
NSLog(@"注销");
[[PoolSdk shareSDK] logoutSDK];
}
@end