gomarketme-react-native 1.0.18 → 1.1.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/dist/index.d.ts +1 -1
- package/dist/index.js +98 -82
- package/package.json +11 -4
- package/src/index.tsx +68 -56
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g
|
|
13
|
-
return g
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -41,6 +41,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
var react_native_1 = require("react-native");
|
|
43
43
|
var react_native_device_info_1 = __importDefault(require("react-native-device-info"));
|
|
44
|
+
var get_user_locale_1 = __importDefault(require("get-user-locale"));
|
|
45
|
+
var async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
|
|
44
46
|
var react_native_iap_1 = __importDefault(require("react-native-iap"));
|
|
45
47
|
var axios_1 = __importDefault(require("axios"));
|
|
46
48
|
var GoMarketMe = /** @class */ (function () {
|
|
@@ -51,6 +53,9 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
51
53
|
this.sdkInitializationUrl = 'https://api.gomarketme.net/v1/sdk-initialization';
|
|
52
54
|
this.systemInfoUrl = 'https://api.gomarketme.net/v1/mobile/system-info';
|
|
53
55
|
this.eventUrl = 'https://api.gomarketme.net/v1/event';
|
|
56
|
+
this.getTimeZone = function () {
|
|
57
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
58
|
+
};
|
|
54
59
|
}
|
|
55
60
|
GoMarketMe.getInstance = function () {
|
|
56
61
|
if (!GoMarketMe.instance) {
|
|
@@ -119,7 +124,7 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
119
124
|
};
|
|
120
125
|
GoMarketMe.prototype.getSystemInfo = function () {
|
|
121
126
|
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
-
var deviceData, _a, _b, devicePixelRatio, windowData;
|
|
127
|
+
var deviceData, _a, _b, devicePixelRatio, dimension, windowData;
|
|
123
128
|
var _c;
|
|
124
129
|
return __generator(this, function (_d) {
|
|
125
130
|
switch (_d.label) {
|
|
@@ -134,15 +139,16 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
134
139
|
deviceData = _b.apply(_a, [(_c.android = _d.sent(),
|
|
135
140
|
_c)]);
|
|
136
141
|
devicePixelRatio = react_native_1.PixelRatio.get();
|
|
142
|
+
dimension = react_native_1.Dimensions.get('window');
|
|
137
143
|
windowData = {
|
|
138
144
|
devicePixelRatio: devicePixelRatio,
|
|
139
|
-
width:
|
|
140
|
-
height:
|
|
145
|
+
width: dimension.width * devicePixelRatio,
|
|
146
|
+
height: dimension.height * devicePixelRatio,
|
|
141
147
|
};
|
|
142
148
|
return [2 /*return*/, {
|
|
143
149
|
device_info: deviceData,
|
|
144
150
|
window_info: windowData,
|
|
145
|
-
|
|
151
|
+
time_zone: this.getTimeZone(),
|
|
146
152
|
language_code: this.getLanguageCode(),
|
|
147
153
|
}];
|
|
148
154
|
}
|
|
@@ -221,98 +227,96 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
221
227
|
};
|
|
222
228
|
GoMarketMe.prototype.readAndroidDeviceInfo = function () {
|
|
223
229
|
return __awaiter(this, void 0, void 0, function () {
|
|
224
|
-
var
|
|
225
|
-
return __generator(this, function (
|
|
226
|
-
switch (
|
|
227
|
-
case 0:
|
|
228
|
-
_a = {};
|
|
229
|
-
return [4 /*yield*/, react_native_device_info_1.default.getAndroidId()];
|
|
230
|
+
var androidId, uniqueId, deviceId, systemName, systemVersion, brand, model, manufacturer, isEmulator;
|
|
231
|
+
return __generator(this, function (_a) {
|
|
232
|
+
switch (_a.label) {
|
|
233
|
+
case 0: return [4 /*yield*/, react_native_device_info_1.default.getAndroidId()];
|
|
230
234
|
case 1:
|
|
231
|
-
|
|
232
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
235
|
+
androidId = _a.sent();
|
|
236
|
+
return [4 /*yield*/, react_native_device_info_1.default.getUniqueId()];
|
|
233
237
|
case 2:
|
|
234
|
-
|
|
235
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
238
|
+
uniqueId = _a.sent();
|
|
239
|
+
return [4 /*yield*/, react_native_device_info_1.default.getDeviceId()];
|
|
236
240
|
case 3:
|
|
237
|
-
|
|
238
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
241
|
+
deviceId = _a.sent();
|
|
242
|
+
return [4 /*yield*/, react_native_device_info_1.default.getSystemName()];
|
|
239
243
|
case 4:
|
|
240
|
-
|
|
241
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
244
|
+
systemName = _a.sent();
|
|
245
|
+
return [4 /*yield*/, react_native_device_info_1.default.getSystemVersion()];
|
|
242
246
|
case 5:
|
|
243
|
-
|
|
244
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
247
|
+
systemVersion = _a.sent();
|
|
248
|
+
return [4 /*yield*/, react_native_device_info_1.default.getBrand()];
|
|
245
249
|
case 6:
|
|
246
|
-
|
|
247
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
250
|
+
brand = _a.sent();
|
|
251
|
+
return [4 /*yield*/, react_native_device_info_1.default.getModel()];
|
|
248
252
|
case 7:
|
|
249
|
-
|
|
250
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
253
|
+
model = _a.sent();
|
|
254
|
+
return [4 /*yield*/, react_native_device_info_1.default.getManufacturer()];
|
|
251
255
|
case 8:
|
|
252
|
-
|
|
253
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
254
|
-
case 9:
|
|
255
|
-
|
|
256
|
+
manufacturer = _a.sent();
|
|
257
|
+
return [4 /*yield*/, react_native_device_info_1.default.isEmulator()];
|
|
258
|
+
case 9:
|
|
259
|
+
isEmulator = _a.sent();
|
|
260
|
+
return [2 /*return*/, {
|
|
261
|
+
deviceId: androidId,
|
|
262
|
+
_deviceId: deviceId,
|
|
263
|
+
_uniqueId: uniqueId,
|
|
264
|
+
systemName: systemName,
|
|
265
|
+
systemVersion: systemVersion,
|
|
266
|
+
brand: brand,
|
|
267
|
+
model: model,
|
|
268
|
+
manufacturer: manufacturer,
|
|
269
|
+
isEmulator: isEmulator
|
|
270
|
+
}];
|
|
256
271
|
}
|
|
257
272
|
});
|
|
258
273
|
});
|
|
259
274
|
};
|
|
260
275
|
GoMarketMe.prototype.readIosDeviceInfo = function () {
|
|
261
276
|
return __awaiter(this, void 0, void 0, function () {
|
|
262
|
-
var
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
case 0:
|
|
267
|
-
_a = {};
|
|
268
|
-
return [4 /*yield*/, react_native_device_info_1.default.getUniqueId()];
|
|
277
|
+
var uniqueId, deviceId, systemName, systemVersion, brand, model, manufacturer, isEmulator;
|
|
278
|
+
return __generator(this, function (_a) {
|
|
279
|
+
switch (_a.label) {
|
|
280
|
+
case 0: return [4 /*yield*/, react_native_device_info_1.default.getUniqueId()];
|
|
269
281
|
case 1:
|
|
270
|
-
|
|
282
|
+
uniqueId = _a.sent();
|
|
271
283
|
return [4 /*yield*/, react_native_device_info_1.default.getDeviceId()];
|
|
272
284
|
case 2:
|
|
273
|
-
|
|
285
|
+
deviceId = _a.sent();
|
|
274
286
|
return [4 /*yield*/, react_native_device_info_1.default.getSystemName()];
|
|
275
287
|
case 3:
|
|
276
|
-
|
|
288
|
+
systemName = _a.sent();
|
|
277
289
|
return [4 /*yield*/, react_native_device_info_1.default.getSystemVersion()];
|
|
278
290
|
case 4:
|
|
279
|
-
|
|
291
|
+
systemVersion = _a.sent();
|
|
280
292
|
return [4 /*yield*/, react_native_device_info_1.default.getBrand()];
|
|
281
293
|
case 5:
|
|
282
|
-
|
|
294
|
+
brand = _a.sent();
|
|
283
295
|
return [4 /*yield*/, react_native_device_info_1.default.getModel()];
|
|
284
296
|
case 6:
|
|
285
|
-
|
|
297
|
+
model = _a.sent();
|
|
286
298
|
return [4 /*yield*/, react_native_device_info_1.default.getManufacturer()];
|
|
287
299
|
case 7:
|
|
288
|
-
|
|
300
|
+
manufacturer = _a.sent();
|
|
289
301
|
return [4 /*yield*/, react_native_device_info_1.default.isEmulator()];
|
|
290
302
|
case 8:
|
|
291
|
-
|
|
292
|
-
return [
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
303
|
+
isEmulator = _a.sent();
|
|
304
|
+
return [2 /*return*/, {
|
|
305
|
+
deviceId: uniqueId,
|
|
306
|
+
_deviceId: deviceId,
|
|
307
|
+
systemName: systemName,
|
|
308
|
+
systemVersion: systemVersion,
|
|
309
|
+
brand: brand,
|
|
310
|
+
model: model,
|
|
311
|
+
manufacturer: manufacturer,
|
|
312
|
+
isEmulator: isEmulator
|
|
313
|
+
}];
|
|
297
314
|
}
|
|
298
315
|
});
|
|
299
316
|
});
|
|
300
317
|
};
|
|
301
|
-
GoMarketMe.prototype.getTimeZoneCode = function () {
|
|
302
|
-
// Convert the time zone to GMT format (e.g., "GMT+2")
|
|
303
|
-
var timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
304
|
-
var date = new Date();
|
|
305
|
-
var timezoneOffset = date.getTimezoneOffset(); // in minutes
|
|
306
|
-
var absOffset = Math.abs(timezoneOffset);
|
|
307
|
-
var hours = Math.floor(absOffset / 60);
|
|
308
|
-
var minutes = absOffset % 60;
|
|
309
|
-
var sign = timezoneOffset > 0 ? '-' : '+';
|
|
310
|
-
return "GMT".concat(sign).concat(String(hours).padStart(2, '0'), ":").concat(String(minutes).padStart(2, '0')); // Return GMT format
|
|
311
|
-
};
|
|
312
318
|
GoMarketMe.prototype.getLanguageCode = function () {
|
|
313
|
-
|
|
314
|
-
//return locales.length > 0 ? locales[0].languageTag : 'en-US';
|
|
315
|
-
return 'en-US';
|
|
319
|
+
return (0, get_user_locale_1.default)();
|
|
316
320
|
};
|
|
317
321
|
GoMarketMe.prototype.fetchPurchases = function (purchaseDetailsList, apiKey) {
|
|
318
322
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -349,7 +353,7 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
349
353
|
switch (_a.label) {
|
|
350
354
|
case 0:
|
|
351
355
|
_a.trys.push([0, 9, , 10]);
|
|
352
|
-
return [4 /*yield*/, react_native_iap_1.default.getProducts(
|
|
356
|
+
return [4 /*yield*/, react_native_iap_1.default.getProducts(productIds)];
|
|
353
357
|
case 1:
|
|
354
358
|
products = _a.sent();
|
|
355
359
|
if (!(products.length > 0)) return [3 /*break*/, 6];
|
|
@@ -422,7 +426,7 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
422
426
|
purchaseID: purchase.transactionId || '',
|
|
423
427
|
transactionDate: purchase.transactionDate || '',
|
|
424
428
|
status: react_native_1.Platform.select({
|
|
425
|
-
ios: purchase.transactionStateIOS,
|
|
429
|
+
ios: purchase.transactionStateIOS,
|
|
426
430
|
android: purchase.purchaseStateAndroid,
|
|
427
431
|
}),
|
|
428
432
|
verificationData: {
|
|
@@ -442,29 +446,41 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
442
446
|
};
|
|
443
447
|
GoMarketMe.prototype.markSDKAsInitialized = function () {
|
|
444
448
|
return __awaiter(this, void 0, void 0, function () {
|
|
449
|
+
var e_6;
|
|
445
450
|
return __generator(this, function (_a) {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
451
|
+
switch (_a.label) {
|
|
452
|
+
case 0:
|
|
453
|
+
_a.trys.push([0, 2, , 3]);
|
|
454
|
+
return [4 /*yield*/, async_storage_1.default.setItem(this.sdkInitializedKey, 'true')];
|
|
455
|
+
case 1:
|
|
456
|
+
_a.sent();
|
|
457
|
+
return [2 /*return*/, true];
|
|
458
|
+
case 2:
|
|
459
|
+
e_6 = _a.sent();
|
|
460
|
+
console.error('Failed to save SDK initialization:', e_6);
|
|
461
|
+
return [2 /*return*/, false];
|
|
462
|
+
case 3: return [2 /*return*/];
|
|
463
|
+
}
|
|
454
464
|
});
|
|
455
465
|
});
|
|
456
466
|
};
|
|
457
467
|
GoMarketMe.prototype.isSDKInitialized = function () {
|
|
458
468
|
return __awaiter(this, void 0, void 0, function () {
|
|
469
|
+
var value, e_7;
|
|
459
470
|
return __generator(this, function (_a) {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
471
|
+
switch (_a.label) {
|
|
472
|
+
case 0:
|
|
473
|
+
_a.trys.push([0, 2, , 3]);
|
|
474
|
+
return [4 /*yield*/, async_storage_1.default.getItem(this.sdkInitializedKey)];
|
|
475
|
+
case 1:
|
|
476
|
+
value = _a.sent();
|
|
477
|
+
return [2 /*return*/, value === 'true'];
|
|
478
|
+
case 2:
|
|
479
|
+
e_7 = _a.sent();
|
|
480
|
+
console.error('Failed to load SDK initialization:', e_7);
|
|
481
|
+
return [2 /*return*/, false];
|
|
482
|
+
case 3: return [2 /*return*/];
|
|
483
|
+
}
|
|
468
484
|
});
|
|
469
485
|
});
|
|
470
486
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gomarketme-react-native",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Affiliate Marketing for React Native-Based iOS and Android Apps.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,12 +18,19 @@
|
|
|
18
18
|
"author": "GoMarketMe",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"
|
|
21
|
+
"@react-native-async-storage/async-storage": "^1.15.6",
|
|
22
|
+
"axios": "^0.21.1",
|
|
23
|
+
"get-user-locale": "^2.3.2",
|
|
22
24
|
"react-native-device-info": "^14.0.0",
|
|
23
|
-
"react-native-iap": "
|
|
25
|
+
"react-native-iap": "^7.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^15.12.5",
|
|
29
|
+
"@types/react-native": "^0.64.12",
|
|
30
|
+
"typescript": "^4.3.5"
|
|
24
31
|
},
|
|
25
32
|
"peerDependencies": {
|
|
26
|
-
"react": "
|
|
33
|
+
"react": "*",
|
|
27
34
|
"react-native": "*"
|
|
28
35
|
}
|
|
29
36
|
}
|
package/src/index.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Platform, Dimensions, PixelRatio } from 'react-native';
|
|
2
2
|
import DeviceInfo from 'react-native-device-info';
|
|
3
|
+
import getUserLocale from 'get-user-locale'
|
|
4
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
3
5
|
import InAppPurchase, { Purchase, Product, ProductPurchase } from 'react-native-iap';
|
|
4
6
|
import axios from 'axios';
|
|
5
7
|
|
|
@@ -49,19 +51,20 @@ class GoMarketMe {
|
|
|
49
51
|
ios: await this.readIosDeviceInfo(),
|
|
50
52
|
android: await this.readAndroidDeviceInfo(),
|
|
51
53
|
});
|
|
52
|
-
|
|
54
|
+
|
|
53
55
|
const devicePixelRatio = PixelRatio.get();
|
|
54
|
-
|
|
56
|
+
const dimension = Dimensions.get('window');
|
|
57
|
+
|
|
55
58
|
const windowData = {
|
|
56
59
|
devicePixelRatio: devicePixelRatio,
|
|
57
|
-
width:
|
|
58
|
-
height:
|
|
60
|
+
width: dimension.width * devicePixelRatio,
|
|
61
|
+
height: dimension.height * devicePixelRatio,
|
|
59
62
|
};
|
|
60
|
-
|
|
63
|
+
|
|
61
64
|
return {
|
|
62
65
|
device_info: deviceData,
|
|
63
66
|
window_info: windowData,
|
|
64
|
-
|
|
67
|
+
time_zone: this.getTimeZone(),
|
|
65
68
|
language_code: this.getLanguageCode(),
|
|
66
69
|
};
|
|
67
70
|
}
|
|
@@ -100,6 +103,7 @@ class GoMarketMe {
|
|
|
100
103
|
if (responseData.device_id) {
|
|
101
104
|
this.deviceId = responseData.device_id;
|
|
102
105
|
}
|
|
106
|
+
|
|
103
107
|
} else {
|
|
104
108
|
console.error('Failed to send system info. Status code:', response.status);
|
|
105
109
|
}
|
|
@@ -109,49 +113,59 @@ class GoMarketMe {
|
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
private async readAndroidDeviceInfo(): Promise<any> {
|
|
116
|
+
|
|
117
|
+
let androidId = await DeviceInfo.getAndroidId();
|
|
118
|
+
let uniqueId = await DeviceInfo.getUniqueId();
|
|
119
|
+
let deviceId = await DeviceInfo.getDeviceId(); // model
|
|
120
|
+
let systemName = await DeviceInfo.getSystemName();
|
|
121
|
+
let systemVersion = await DeviceInfo.getSystemVersion()
|
|
122
|
+
let brand = await DeviceInfo.getBrand();
|
|
123
|
+
let model = await DeviceInfo.getModel();
|
|
124
|
+
let manufacturer = await DeviceInfo.getManufacturer();
|
|
125
|
+
let isEmulator = await DeviceInfo.isEmulator();
|
|
126
|
+
|
|
112
127
|
return {
|
|
113
|
-
deviceId:
|
|
114
|
-
_deviceId:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
128
|
+
deviceId: androidId,
|
|
129
|
+
_deviceId: deviceId,
|
|
130
|
+
_uniqueId: uniqueId,
|
|
131
|
+
systemName: systemName,
|
|
132
|
+
systemVersion: systemVersion,
|
|
133
|
+
brand: brand,
|
|
134
|
+
model: model,
|
|
135
|
+
manufacturer: manufacturer,
|
|
136
|
+
isEmulator: isEmulator
|
|
122
137
|
};
|
|
123
138
|
}
|
|
124
139
|
|
|
125
140
|
private async readIosDeviceInfo(): Promise<any> {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
|
|
142
|
+
let uniqueId = await DeviceInfo.getUniqueId();
|
|
143
|
+
let deviceId = await DeviceInfo.getDeviceId(); // model
|
|
144
|
+
let systemName = await DeviceInfo.getSystemName();
|
|
145
|
+
let systemVersion = await DeviceInfo.getSystemVersion()
|
|
146
|
+
let brand = await DeviceInfo.getBrand();
|
|
147
|
+
let model = await DeviceInfo.getModel();
|
|
148
|
+
let manufacturer = await DeviceInfo.getManufacturer();
|
|
149
|
+
let isEmulator = await DeviceInfo.isEmulator();
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
deviceId: uniqueId,
|
|
153
|
+
_deviceId: deviceId,
|
|
154
|
+
systemName: systemName,
|
|
155
|
+
systemVersion: systemVersion,
|
|
156
|
+
brand: brand,
|
|
157
|
+
model: model,
|
|
158
|
+
manufacturer: manufacturer,
|
|
159
|
+
isEmulator: isEmulator
|
|
136
160
|
};
|
|
137
161
|
}
|
|
138
162
|
|
|
139
|
-
private
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const date = new Date();
|
|
143
|
-
const timezoneOffset = date.getTimezoneOffset(); // in minutes
|
|
144
|
-
const absOffset = Math.abs(timezoneOffset);
|
|
145
|
-
const hours = Math.floor(absOffset / 60);
|
|
146
|
-
const minutes = absOffset % 60;
|
|
147
|
-
const sign = timezoneOffset > 0 ? '-' : '+';
|
|
148
|
-
return `GMT${sign}${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`; // Return GMT format
|
|
149
|
-
}
|
|
163
|
+
private getTimeZone = (): string => {
|
|
164
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
165
|
+
};
|
|
150
166
|
|
|
151
167
|
private getLanguageCode(): string {
|
|
152
|
-
|
|
153
|
-
//return locales.length > 0 ? locales[0].languageTag : 'en-US';
|
|
154
|
-
return 'en-US';
|
|
168
|
+
return getUserLocale();
|
|
155
169
|
}
|
|
156
170
|
|
|
157
171
|
private async fetchPurchases(purchaseDetailsList: Purchase[], apiKey: string): Promise<string[]> {
|
|
@@ -169,7 +183,7 @@ class GoMarketMe {
|
|
|
169
183
|
|
|
170
184
|
private async fetchPurchaseProducts(productIds: string[], apiKey: string): Promise<void> {
|
|
171
185
|
try {
|
|
172
|
-
const products = await InAppPurchase.getProducts(
|
|
186
|
+
const products = await InAppPurchase.getProducts(productIds);
|
|
173
187
|
if (products.length > 0) {
|
|
174
188
|
for (const product of products) {
|
|
175
189
|
await this.sendEventToServer(JSON.stringify(this.serializeProductDetails(product)), 'product', apiKey);
|
|
@@ -232,25 +246,23 @@ class GoMarketMe {
|
|
|
232
246
|
}
|
|
233
247
|
|
|
234
248
|
private async markSDKAsInitialized(): Promise<boolean> {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
return true;
|
|
249
|
+
try {
|
|
250
|
+
await AsyncStorage.setItem(this.sdkInitializedKey, 'true');
|
|
251
|
+
return true;
|
|
252
|
+
} catch (e) {
|
|
253
|
+
console.error('Failed to save SDK initialization:', e);
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
243
256
|
}
|
|
244
257
|
|
|
245
258
|
private async isSDKInitialized(): Promise<boolean> {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
return false;
|
|
259
|
+
try {
|
|
260
|
+
const value = await AsyncStorage.getItem(this.sdkInitializedKey);
|
|
261
|
+
return value === 'true';
|
|
262
|
+
} catch (e) {
|
|
263
|
+
console.error('Failed to load SDK initialization:', e);
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
254
266
|
}
|
|
255
267
|
}
|
|
256
268
|
|