-
Notifications
You must be signed in to change notification settings - Fork 0
/
OceanConversion.js
90 lines (78 loc) · 3.74 KB
/
OceanConversion.js
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
var exec = require('cordova/exec');
module.exports = {
init(params, onSuccess, onError) {
if (!params) {
params = {};
}
exec(onSuccess, onError, 'OceanConversion', 'init', [params]);
},
onEventRegister(type, success, onSuccess, onError) {
exec(onSuccess, onError, 'OceanConversion', 'onEventRegister', [type, success]);
},
onEventPurchase(type, name, id, num, channel, currency, success, price, onSuccess, onError) {
exec(onSuccess, onError, 'OceanConversion', 'onEventPurchase', [type, name, id, num, channel, currency, success, price]);
},
onEventV3(event, params, onSuccess, onError) {
exec(onSuccess, onError, 'OceanConversion', 'onEventV3', [event, params]);
},
onGameAddiction(event, onSuccess, onError) {
exec(onSuccess, onError, 'OceanConversion', 'onEventV3', ["game_addiction", { origin_event: event }]);
},
setUserUniqueID(account, onSuccess, onError) {
exec(onSuccess, onError, 'OceanConversion', 'setUserUniqueID', [account]);
},
getChannel(onSuccess, onError) {
exec(onSuccess, onError, 'OceanConversion', 'getChannel', []);
},
testApi(params, callback) {
var initParams = { channel: "testOcean", logEnable: true };
if (params) {
initParams = {
channel: "testOcean",
logEnable: true,
...params
}
}
var _this = this;
try {
this.init(
initParams,
() => {
console.log("Ocean SDK init success");
_this.onEventRegister("wechat", true);
_this.onEventPurchase("product", "diamond", "product_1", 1, "alipay", "¥", true, 6);
_this.onGameAddiction("Event-MaMaMiAhh");
_this.onEventV3("purchase_item_clicked", { product_title: "PiPiAppleApplePi", duration: 200, history_bought: false });
_this.setUserUniqueID("user1");
_this.onEventRegister("qq", true);
_this.onEventPurchase("product", "diamond", "product_1", 1, "qq", "¥", true, 6);
_this.onGameAddiction("Event-MaMaMiAhh");
_this.onEventV3("purchase_item_clicked", { product_title: "PiPiAppleApplePi", duration: 200, history_bought: false });
_this.setUserUniqueID(null);
_this.onEventRegister("qq", true);
_this.onEventPurchase("product", "diamond", "product_1", 1, "qq", "¥", true, 6);
_this.onGameAddiction("Event-MaMaMiAhh");
_this.onEventV3("purchase_item_clicked", { product_title: "PiPiAppleApplePi", duration: 200, history_bought: false });
_this.setUserUniqueID("user2");
_this.onEventRegister("apple", true);
_this.onEventPurchase("product", "diamond", "product_1", 1, "applePay", "¥", true, 6);
_this.onGameAddiction("Event-MaMaMiAhh");
_this.onEventV3("purchase_item_clicked", { product_title: "PiPiAppleApplePi", duration: 200, history_bought: true });
_this.setUserUniqueID(null);
console.log("test api success ! ! !");
if (callback)
callback(true);
},
() => {
console.error("Ocean SDK init failed");
if (callback)
callback(false);
}
)
} catch (err) {
console.error("Ocean SDK init failed", err);
if (callback)
callback(false);
}
}
}