cordova-plugin-insider 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CODEOWNERS +8 -0
- package/.github/workflows/git-leak.yml +25 -0
- package/.github/workflows/insider-cordova-SDK_release.yml +61 -0
- package/.github/workflows/release_task_merger.yml +22 -0
- package/.github/workflows/release_version_setter.yml +43 -0
- package/README.md +104 -0
- package/hooks/FSUtils.js +28 -0
- package/hooks/after_plugin_install.js +81 -0
- package/hooks/before_plugin_uninstall.js +49 -0
- package/package.json +19 -0
- package/plugin.xml +91 -0
- package/release_version.sh +27 -0
- package/slack_notifier.sh +20 -0
- package/src/android/CDVUtils.java +120 -0
- package/src/android/Constants.java +41 -0
- package/src/android/InsiderPlugin.java +814 -0
- package/src/android/build-extras.gradle +38 -0
- package/src/android/res/values/dimens.xml +4 -0
- package/src/android/res/values-sw600dp/dimens.xml +3 -0
- package/src/android/res/values-sw720dp/dimens.xml +3 -0
- package/src/android/res/values-xhdpi/dimens.xml +4 -0
- package/src/android/res/values-xxhdpi/dimens.xml +4 -0
- package/src/android/res/values-xxxhdpi/dimens.xml +4 -0
- package/src/ios/IDFAHelper.h +7 -0
- package/src/ios/IDFAHelper.m +19 -0
- package/src/ios/InsiderPlugin.h +58 -0
- package/src/ios/InsiderPlugin.m +758 -0
- package/types/CallbackType.d.ts +7 -0
- package/types/ContentOptimizerDataType.d.ts +4 -0
- package/types/Event.d.ts +9 -0
- package/types/Gender.d.ts +5 -0
- package/types/Identifier.d.ts +7 -0
- package/types/InsiderPlugin.d.ts +51 -0
- package/types/Product.d.ts +18 -0
- package/types/User.d.ts +27 -0
- package/www/CallbackType.js +7 -0
- package/www/Constants.js +86 -0
- package/www/ContentOptimizerDataType.js +4 -0
- package/www/Event.js +96 -0
- package/www/Gender.js +5 -0
- package/www/Identifier.js +66 -0
- package/www/InsiderPlugin.js +364 -0
- package/www/Product.js +211 -0
- package/www/User.js +303 -0
- package/www/Utils.js +18 -0
package/www/User.js
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Utils = require("./Utils");
|
|
4
|
+
const InsiderConstants = require("./Constants");
|
|
5
|
+
|
|
6
|
+
class User {
|
|
7
|
+
constructor() {}
|
|
8
|
+
|
|
9
|
+
setGender(gender) {
|
|
10
|
+
if (gender === null || Utils.isEmpty(gender)){ Utils.showWarning(this.constructor.name + '-gender'); return this;}
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_GENDER, [gender]);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
setBirthday(birthday) {
|
|
22
|
+
if (birthday === null || Utils.isEmpty(birthday)){ Utils.showWarning(this.constructor.name + '-birthday'); return this;}
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_BIRTDAY, [birthday.toISOString()]);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
28
|
+
}
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
setName(name) {
|
|
33
|
+
if (name === null || Utils.isEmpty(name)){ Utils.showWarning(this.constructor.name + '-name'); return this;}
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_NAME, [name]);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
39
|
+
}
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setSurname(surname) {
|
|
44
|
+
if (surname === null || Utils.isEmpty(surname)){ Utils.showWarning(this.constructor.name + '-surname'); return this;}
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_SURNAME, [surname]);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setAge(age) {
|
|
56
|
+
if (age === null || Utils.isEmpty(age)){ Utils.showWarning(this.constructor.name + '-age'); return this;}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_AGE, [age]);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
setEmail(email) {
|
|
69
|
+
if (email === null || Utils.isEmpty(email)){ Utils.showWarning(this.constructor.name + '-email'); return this;}
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_EMAIL, [email]);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setPhoneNumber(phone) {
|
|
81
|
+
if (phone === null || Utils.isEmpty(phone)){ Utils.showWarning(this.constructor.name + '-phone'); return this;}
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_PHONE_NUMBER, [phone]);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
setLanguage(language) {
|
|
93
|
+
if (language === null || Utils.isEmpty(language)){ Utils.showWarning(this.constructor.name + '-language'); return this;}
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_LANGUAGE, [language]);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
setLocale(locale) {
|
|
105
|
+
if (locale === null || Utils.isEmpty(locale)){ Utils.showWarning(this.constructor.name + '-locale'); return this;}
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_LOCALE, [locale]);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
setFacebookID(facebookID) {
|
|
117
|
+
if (facebookID === null || Utils.isEmpty(facebookID)){ Utils.showWarning(this.constructor.name + '-facebookID'); return this;}
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_FACEBOOK_ID, [facebookID]);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
setTwitterID(twitterID) {
|
|
129
|
+
if (twitterID === null || Utils.isEmpty(twitterID)){ Utils.showWarning(this.constructor.name + '-twitterID'); return this;}
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_TWITTER_ID, [twitterID]);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
setEmailOptin(emailOptIn) {
|
|
141
|
+
if (emailOptIn === null || Utils.isEmpty(emailOptIn)){ Utils.showWarning(this.constructor.name + '-emailOptIn'); return this;}
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_EMAIL_OPTIN, [emailOptIn]);
|
|
145
|
+
} catch (error) {
|
|
146
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
setSMSOptin(smsOptIn) {
|
|
153
|
+
if (smsOptIn === null || Utils.isEmpty(smsOptIn)){ Utils.showWarning(this.constructor.name + '-smsOptIn'); return this;}
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_SMS_OPTIN, [smsOptIn]);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
159
|
+
}
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
setPushOptin(pushOptIn) {
|
|
164
|
+
if (pushOptIn === null || Utils.isEmpty(pushOptIn)){ Utils.showWarning(this.constructor.name + '-pushOptIn'); return this;}
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_PUSH_OPTIN, [pushOptIn]);
|
|
168
|
+
} catch (error) {
|
|
169
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
setLocationOptin(locationOptIn) {
|
|
176
|
+
if (locationOptIn === null || locationOptIn == undefined) { Utils.showWarning(this.constructor.name + '-locationOptIn'); return this; }
|
|
177
|
+
|
|
178
|
+
try {
|
|
179
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_LOCATION_OPTIN, [!!locationOptIn]);
|
|
180
|
+
} catch (error) {
|
|
181
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
setWhatsappOptin(whatsappOptin) {
|
|
188
|
+
if (whatsappOptin === null || Utils.isEmpty(whatsappOptin)){ Utils.showWarning(this.constructor.name + '-whatsappOptin'); return this;}
|
|
189
|
+
|
|
190
|
+
try {
|
|
191
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_WHATSAPP_OPTIN, [whatsappOptin]);
|
|
192
|
+
} catch (error) {
|
|
193
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return this;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
login(identifiers, insiderIDResult) {
|
|
200
|
+
try {
|
|
201
|
+
if (insiderIDResult !== null) {
|
|
202
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.LOGIN, [identifiers, insiderIDResult]).then(id => insiderIDResult(id));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.LOGIN, [identifiers]);
|
|
206
|
+
} catch (error) {
|
|
207
|
+
Utils.asyncExec(InsiderCordovaPlugin, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
logout() {
|
|
212
|
+
try {
|
|
213
|
+
return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.LOGOUT, []);
|
|
214
|
+
} catch (error) {
|
|
215
|
+
Utils.asyncExec(InsiderCordovaPlugin, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
setCustomAttributeWithString(key, value) {
|
|
220
|
+
if (key == null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithString key or value'); return this;}
|
|
221
|
+
|
|
222
|
+
try {
|
|
223
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_STRING, [key, value]);
|
|
224
|
+
} catch (error) {
|
|
225
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return this;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
setCustomAttributeWithInt(key, value) {
|
|
232
|
+
if (key == null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithInt key or value'); return this;}
|
|
233
|
+
|
|
234
|
+
try {
|
|
235
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_INT, [key, value]);
|
|
236
|
+
} catch (error) {
|
|
237
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return this;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
setCustomAttributeWithDouble(key, value) {
|
|
244
|
+
if (key == null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithDouble key or value'); return this;}
|
|
245
|
+
|
|
246
|
+
try {
|
|
247
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_DOUBLE, [key, value]);
|
|
248
|
+
} catch (error) {
|
|
249
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return this;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
setCustomAttributeWithBoolean(key, value) {
|
|
256
|
+
if (key == null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithBoolean key or value'); return this;}
|
|
257
|
+
|
|
258
|
+
try {
|
|
259
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_BOOLEAN, [key, value]);
|
|
260
|
+
} catch (error) {
|
|
261
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return this;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
setCustomAttributeWithDate(key, value) {
|
|
268
|
+
if (key == null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithDate key or value'); return this;}
|
|
269
|
+
|
|
270
|
+
try {
|
|
271
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_DATE, [key, value.toISOString()]);
|
|
272
|
+
} catch (error) {
|
|
273
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return this;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
setCustomAttributeWithArray(key, value) {
|
|
280
|
+
if (key == null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-setCustomAttributeWithArray key or value'); return this;}
|
|
281
|
+
|
|
282
|
+
try {
|
|
283
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.SET_CUSTOM_ATTRIBUTE_WITH_ARRAY, [key, value]);
|
|
284
|
+
} catch (error) {
|
|
285
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return this;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
unsetCustomAttribute(key) {
|
|
292
|
+
if (key == null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-unsetCustomAttribute key'); return this;}
|
|
293
|
+
try {
|
|
294
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.UNSET_CUSTOM_ATTRIBUTE, [key]);
|
|
295
|
+
} catch (error) {
|
|
296
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return this;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
module.exports = User;
|
package/www/Utils.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
asyncExec: (className, reference, args = []) => {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
window.cordova.exec(resolve, reject, className, reference, args);
|
|
7
|
+
});
|
|
8
|
+
},
|
|
9
|
+
generateJSONErrorString: (error) => {
|
|
10
|
+
return ('[JavaScript Error] ' + error);
|
|
11
|
+
},
|
|
12
|
+
isEmpty(str) {
|
|
13
|
+
return (!str || str.length === 0 );
|
|
14
|
+
},
|
|
15
|
+
showWarning(name){
|
|
16
|
+
console.log("[InsiderPlugin Warning] Value is null or empty: " + name);
|
|
17
|
+
}
|
|
18
|
+
};
|