PoolSdk.m
3.83 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
//
// PoolSdk.m
// PoolSdk
//
// Created by winFan on 11/23/15.
// Copyright (c) 2015 winFan. All rights reserved.
//
#import "PoolSdk.h"
#import "SDKInterface.h"
static PoolSdk *s_PoolSdkCerterInstance = nil;
static id<UnionInterface> _interface = nil;
@implementation PoolSdk : NSObject
- (id)init
{
if(self = [super init])
{
_sdkVersion = [NSString stringWithFormat:@"%@ - %@",[[PoolConfig getInstance] gameSimpleName], [[PoolConfig getInstance] sdkSimpleName]];
_interface = [[SDKInterface alloc] init];
self.urlSchemes = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
}
return self;
}
- (void)initSDK :(UIViewController *) control
{
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"pool_everLaunched"]) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"pool_everLaunched"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"pool_firstLaunch"];
}
else{
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"pool_firstLaunch"];
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"]) {
}
[_interface SDKinit:control];
[[PoolChecker getInstance] reportSDKOpen];
NSString* channelId = [[PoolConfig getInstance] getValueByKey:@"gamechannelid"];
[TrackingIO initWithappKey:[[PoolConfig getInstance] getValueByKey:@"renyunAppKey"] withChannelId:channelId];
}
/**
获取SDK实例对象
*/
+ (PoolSdk *)shareSDK
{
static dispatch_once_t dgonceToken;
dispatch_once(&dgonceToken, ^{
s_PoolSdkCerterInstance = [[PoolSdk alloc] init];
s_PoolSdkCerterInstance.sdkOrientation = ESDKOrientationLandscape;
s_PoolSdkCerterInstance.bShowedFloat = NO;
});
return s_PoolSdkCerterInstance;
}
-(void)viewDidAppear{
[_interface viewDidAppear];
}
- (void)loginSDK
{
//[[PoolChecker getInstance] reportOpen];
[_interface SDKloginSDK];
}
- (void)payWithPaymentInfo:(PoolCreateOrderInfo *)payInfo
{
[_interface SDKpayWithPaymentInfo:payInfo];
}
- (void)reportSDK:(PoolReportInfo *)reportInfo
{
NSString *reportT = [reportInfo reportType];
reportInfo.openId = [[PoolChecker getInstance] userId];
if ([reportT isEqualToString:REPORT_ENTER]) {
[[PoolChecker getInstance] reportEnter:reportInfo];
NSLog(@"reportSDK enter");
[TrackingIO setLoginWithAccountID:[reportInfo playerId]];
}else if ([reportT isEqualToString:REPORT_ROLEUPGRADE]){
}else if ([reportT isEqualToString:REPORT_CREATEROLE]){
NSLog(@"reportSDK createRole");
[TrackingIO setRegisterWithAccountID:[reportInfo playerId]];
}
// [[PoolChecker getInstance] reportOpen];
[_interface SDKreport:reportInfo];
}
- (void)gotoUserCenter
{
[_interface SDKgotoUserCenter];
}
- (void)logoutSDK
{
[_interface SDKlogoutSDK];
}
- (void)exitSDK
{
[_interface SDKexitSDK];
}
- (void)handleOpenurl:(NSURL *)url
{
NSLog(@"handleOpenurl%@",url);
if([[url host] isEqualToString:@"c_code"]){
NSString* path = url.path;
NSString* codeValue = [path substringFromIndex:1];
[[PoolChecker getInstance] handleFirstOpenApp:codeValue];
}
[_interface handleOpenurl:url];
}
- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return [_interface application:application supportedInterfaceOrientationsForWindow:window];
}
- (NSString *)getGameChannelId{
return [[PoolConfig getInstance]getValueByKey:@"gamechannelid"];
}
- (NSString *)getCustomValue{
return [[PoolConfig getInstance]getValueByKey:@"custom"];
}
- (NSString *)getChannelParameter1{
return [[PoolConfig getInstance]getValueByKey:@"c1"];
}
- (NSString *)getChannelParameter2{
return [[PoolConfig getInstance]getValueByKey:@"c2"];
}
@end