-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOverseaController.m
192 lines (162 loc) · 5.62 KB
/
OverseaController.m
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
//
// OverseaController.m
// OmniSDKDemo
//
// Created by 程小康 on 2023/4/14.
// 海外 SDK 接入代码示例 (OmniSDKChannel=oversea)
#import "OverseaController.h"
@interface OverseaController ()
@end
@implementation OverseaController
- (void)viewDidLoad {
[super viewDidLoad];
self.items = @[
@{@"静默登录":NSStringFromSelector(@selector(login))},
@{@"游客登录":NSStringFromSelector(@selector(loginGuest))},
@{@"AppleID登录":NSStringFromSelector(@selector(loginApple))},
@{@"Facebook登录":NSStringFromSelector(@selector(loginFacebook))},
@{@"登出":NSStringFromSelector(@selector(logout))},
@{@"账号中心":NSStringFromSelector(@selector(accountCenter))},
@{@"关联账号":NSStringFromSelector(@selector(linkCustom))},
@{@"关联Apple":NSStringFromSelector(@selector(linkApple))},
@{@"关联Facebook":NSStringFromSelector(@selector(linkFacebook))},
@{@"删除账号":NSStringFromSelector(@selector(deleteAccount))},
@{@"恢复账号":NSStringFromSelector(@selector(restoreAccount))},
@{@"支付":NSStringFromSelector(@selector(purchase))},
@{@"分享Facebook":NSStringFromSelector(@selector(socialShareFacebook))},
];
[self initSDK];
}
/// 初始化
- (void)initSDK{
OmniSDKOptions *options = [[OmniSDKOptions alloc] init];
options.delegate = self;
[[OmniSDKv3 shared] startWithOptions:options];
}
///静默登录
- (void)login {
[[OmniSDKv3 shared] loginWithController:self options:nil];
}
///游客登录
- (void)loginGuest {
OmniSDKLoginOptions *options = [[OmniSDKLoginOptions alloc] initWithAuthMethod:OmniSDKAuthMethodGuest];
[[OmniSDKv3 shared] loginWithController:self options:options];
}
///AppleID 登录
- (void)loginApple {
OmniSDKLoginOptions *options = [[OmniSDKLoginOptions alloc] initWithAuthMethod:OmniSDKAuthMethodApple];
[[OmniSDKv3 shared] loginWithController:self options:options];
}
///Facebook 登录
- (void)loginFacebook {
OmniSDKLoginOptions *options = [[OmniSDKLoginOptions alloc] initWithAuthMethod:OmniSDKAuthMethodFacebook];
[[OmniSDKv3 shared] loginWithController:self options:options];
}
///登出
- (void)logout {
if (!self.isLogin) {
[self.console updateLogWithLevel:INFO message:@"未登录"];
return;
}
[[OmniSDKv3 shared] logout];
}
#pragma mark - 用户中心
- (void)accountCenter {
if (!self.isLogin) {
[Utils showAlertWithContrller:self msg:@"请先登录"];
return;
}
[OmniSDKv3.shared openAccountCenterWithController:self];
}
#pragma mark - 应用内购买
/// 购买
- (void)purchase {
if (!self.isLogin) {
[Utils showAlertWithContrller:self msg:@"请先登录"];
return;
}
NSString *gameTradeNo = [Utils getCurrentTimes];
[OmniSDKv3.shared purchaseWithOptions:[self purchaseOptions:gameTradeNo]];
}
#pragma mark - 删除账号
/// 申请删除账号
- (void)deleteAccount {
if (!self.isLogin) {
[Utils showAlertWithContrller:self msg:@"请先登录"];
return;
}
[OmniSDKv3.shared deleteAccountWithOptions:nil];
}
/// 恢复账号
- (void)restoreAccount {
if (!self.isLogin) {
[Utils showAlertWithContrller:self msg:@"请先登录"];
return;
}
[OmniSDKv3.shared restoreAccountWithOptions:nil];
}
#pragma mark - 关联账号
/// 自定义关联
- (void)linkCustom {
if (!self.isLogin) {
[Utils showAlertWithContrller:self msg:@"请先登录"];
return;
}
[OmniSDKv3.shared linkAccountWithOptions:nil];
}
/// 关联 AppleID
- (void)linkApple {
OmniSDKLinkAccountOptions *options = [[OmniSDKLinkAccountOptions alloc] initWithIdp:OmniSDKIdentityProviderApple];
[OmniSDKv3.shared linkAccountWithOptions:options];
}
/// 关联 Facebook
- (void)linkFacebook {
OmniSDKLinkAccountOptions *options = [[OmniSDKLinkAccountOptions alloc] initWithIdp:OmniSDKIdentityProviderFacebook];
[OmniSDKv3.shared linkAccountWithOptions:options];
}
#pragma mark - 分享
/// 系统分享
- (void)socialShareSystem {
if (!self.isLogin) {
[Utils showAlertWithContrller:self msg:@"请先登录"];
return;
}
[self socialShare:OmniSDKSocialSharePlatformSystem];
}
/// 分享到 Facebook
- (void)socialShareFacebook {
if (!self.isLogin) {
[Utils showAlertWithContrller:self msg:@"请先登录"];
return;
}
[self socialShare:OmniSDKSocialSharePlatformFacebook];
}
/// 分享到 Line
- (void)socialShareLine {
if (!self.isLogin) {
[Utils showAlertWithContrller:self msg:@"请先登录"];
return;
}
[self socialShare:OmniSDKSocialSharePlatformLine];
}
- (void)socialShare:(OmniSDKSocialSharePlatform)platform {
OmniSDKSocialShareOptions *options = [[OmniSDKSocialShareOptions alloc] init];
options.platform = platform;
options.linkUrl = [NSURL URLWithString:@"https://developers.facebook.com"];
options.text = @"test share";
options.imageUrl = [NSURL URLWithString:@"https://lmg.jj20.com/up/allimg/4k/s/02/2109250006343S5-0-lp.jpg"];
[[OmniSDKv3 shared] socialShareWithController:self options:options];
}
#pragma mark - Other Function
- (OmniSDKPurchaseOptions *)purchaseOptions:(NSString *)gameOrder {
OmniSDKPurchaseOptions *options = [[OmniSDKPurchaseOptions alloc] init];
options.gameRoleId = @"123";
options.gameOrderId = gameOrder;
options.gameServerId = @"123";
options.productId = @"com.oversea.product6";
options.productDesc = @"test";
options.purchaseCallbackUrl = @"https://api.seayoo.io/omni/pout/test/cp_notify_ok";
self.purchaseOptions = options;
return options;
}
@end