MainViewController.m
5.94 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
//
// MainViewController.m
// Demo_qiyu
//
// Created by 许 on 17/6/7.
// Copyright © 2017年 winFan. All rights reserved.
//
#import "MainViewController.h"
#import <PoolSdk/PoolSdk2.h>
@interface MainViewController ()
@end
NSString* sdkUserId = @"";
@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.
NSLog(@"viewDidLoad");
}
- (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)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;
sdkUserId = [loginInfo openId];
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;
case PoolSDKNotificationSwitchAccount:
NSLog(@"切换账号通知");
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;
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:@"99887766"];
[payInfo setPlayerName:@"iamrolename"];
[payInfo setPlayerLevel:@"10"];
[payInfo setUserId:sdkUserId];
[payInfo setPostAmount:@"1"];
[payInfo setProductId:@"com.xiongdi.xunqinji.6"];
[payInfo setPlayerId:@"1231241234"];
[payInfo setProductName:@"com.xiongdi.xunqinji.6"];
[payInfo setProductDesc:@"productDes"];
[payInfo setTimestamp:@"1232134"];
[payInfo setExchange:@"10"];
[payInfo setServerName:@"servername"];
[payInfo setCustom:@"custom"];
[[PoolSdk shareSDK] gzyazfWithGzyazfmentInfo:payInfo];
}
-(NSString*)getCurrentTimestamp{
// 时间戳转时间
NSTimeInterval interval = [[NSDate date] timeIntervalSince1970] * 1000;
NSString* timeStr = [[NSString alloc]initWithFormat:@"%.f",interval];
return timeStr;
}
/**
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:@"28"];
[reportInfo setServerName:@"serverName"];
[reportInfo setPlayerId:@"1231241234"];
[reportInfo setPlayerName:@"playName"];
[reportInfo setPlayerLevel:@"10"];
[reportInfo setPartyName:@"1345"];
[reportInfo setRoleCTime:[[NSNumber alloc]initWithLong:[self getCurrentTimestamp].longLongValue]];
[reportInfo setRoleChangeTime:[[NSNumber alloc]initWithLong:[self getCurrentTimestamp].longLongValue]];
[[PoolSdk shareSDK] reportSDK:reportInfo];
}
- (IBAction)actionLogout:(id)sender {
NSLog(@"注销");
if ([[PoolSdk shareSDK] hasLogout]) {
[[PoolSdk shareSDK] logoutSDK];
}
}
- (IBAction)actionSwitchAccount:(id)sender {
if([[PoolSdk shareSDK] hasSwitchAccount]){
[[PoolSdk shareSDK] switchAccount];
}
}
#pragma mark - 截屏
- (void)screenShot:(UIView *)view{
UIImage* image = nil;
UIGraphicsBeginImageContext(view.bounds.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIGraphicsEndImageContext();
if (image != nil) {
NSLog(@"截图成功!");
UIImageWriteToSavedPhotosAlbum(image,self,@selector(image:didFinishSavingWithError:contextInfo:),NULL);
}
}
#pragma mark - 保存到相册
-(void)image:(UIImage *)image didFinishSavingWithError:(NSError*)error contextInfo:(void*)contextInfo
{
if(!error){
NSLog(@"存到相册");
}else{
NSLog(@"存储失败");
}
}
@end