gomarketme-react-native 1.0.18 → 1.1.1
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 +2 -1
- package/dist/index.js +141 -98
- package/package.json +11 -4
- package/src/index.tsx +88 -58
package/dist/index.d.ts
CHANGED
|
@@ -15,13 +15,14 @@ declare class GoMarketMe {
|
|
|
15
15
|
private postSystemInfo;
|
|
16
16
|
private readAndroidDeviceInfo;
|
|
17
17
|
private readIosDeviceInfo;
|
|
18
|
-
private
|
|
18
|
+
private getTimeZone;
|
|
19
19
|
private getLanguageCode;
|
|
20
20
|
private fetchPurchases;
|
|
21
21
|
private fetchPurchaseProducts;
|
|
22
22
|
private sendEventToServer;
|
|
23
23
|
private serializePurchaseDetails;
|
|
24
24
|
private serializeProductDetails;
|
|
25
|
+
private serializeSubscriptionDetails;
|
|
25
26
|
private markSDKAsInitialized;
|
|
26
27
|
private isSDKInitialized;
|
|
27
28
|
}
|
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 () {
|
|
@@ -344,38 +348,55 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
344
348
|
};
|
|
345
349
|
GoMarketMe.prototype.fetchPurchaseProducts = function (productIds, apiKey) {
|
|
346
350
|
return __awaiter(this, void 0, void 0, function () {
|
|
347
|
-
var products, _i, products_1, product, e_4;
|
|
348
|
-
return __generator(this, function (
|
|
349
|
-
switch (
|
|
351
|
+
var products, _i, products_1, product, products_3, _a, products_2, product, e_4;
|
|
352
|
+
return __generator(this, function (_b) {
|
|
353
|
+
switch (_b.label) {
|
|
350
354
|
case 0:
|
|
351
|
-
|
|
352
|
-
return [4 /*yield*/, react_native_iap_1.default.getProducts(
|
|
355
|
+
_b.trys.push([0, 15, , 16]);
|
|
356
|
+
return [4 /*yield*/, react_native_iap_1.default.getProducts(productIds)];
|
|
353
357
|
case 1:
|
|
354
|
-
products =
|
|
358
|
+
products = _b.sent();
|
|
355
359
|
if (!(products.length > 0)) return [3 /*break*/, 6];
|
|
356
360
|
_i = 0, products_1 = products;
|
|
357
|
-
|
|
361
|
+
_b.label = 2;
|
|
358
362
|
case 2:
|
|
359
363
|
if (!(_i < products_1.length)) return [3 /*break*/, 5];
|
|
360
364
|
product = products_1[_i];
|
|
361
365
|
return [4 /*yield*/, this.sendEventToServer(JSON.stringify(this.serializeProductDetails(product)), 'product', apiKey)];
|
|
362
366
|
case 3:
|
|
363
|
-
|
|
364
|
-
|
|
367
|
+
_b.sent();
|
|
368
|
+
_b.label = 4;
|
|
365
369
|
case 4:
|
|
366
370
|
_i++;
|
|
367
371
|
return [3 /*break*/, 2];
|
|
368
|
-
case 5: return [3 /*break*/,
|
|
369
|
-
case 6: return [4 /*yield*/,
|
|
372
|
+
case 5: return [3 /*break*/, 14];
|
|
373
|
+
case 6: return [4 /*yield*/, react_native_iap_1.default.getSubscriptions(productIds)];
|
|
370
374
|
case 7:
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
375
|
+
products_3 = _b.sent();
|
|
376
|
+
if (!(products_3.length > 0)) return [3 /*break*/, 12];
|
|
377
|
+
_a = 0, products_2 = products_3;
|
|
378
|
+
_b.label = 8;
|
|
379
|
+
case 8:
|
|
380
|
+
if (!(_a < products_2.length)) return [3 /*break*/, 11];
|
|
381
|
+
product = products_2[_a];
|
|
382
|
+
return [4 /*yield*/, this.sendEventToServer(JSON.stringify(this.serializeSubscriptionDetails(product)), 'product', apiKey)];
|
|
374
383
|
case 9:
|
|
375
|
-
|
|
384
|
+
_b.sent();
|
|
385
|
+
_b.label = 10;
|
|
386
|
+
case 10:
|
|
387
|
+
_a++;
|
|
388
|
+
return [3 /*break*/, 8];
|
|
389
|
+
case 11: return [3 /*break*/, 14];
|
|
390
|
+
case 12: return [4 /*yield*/, this.sendEventToServer(JSON.stringify({ notFoundIDs: productIds.join(',') }), 'product', apiKey)];
|
|
391
|
+
case 13:
|
|
392
|
+
_b.sent();
|
|
393
|
+
_b.label = 14;
|
|
394
|
+
case 14: return [3 /*break*/, 16];
|
|
395
|
+
case 15:
|
|
396
|
+
e_4 = _b.sent();
|
|
376
397
|
console.error('Error fetching products:', e_4);
|
|
377
|
-
return [3 /*break*/,
|
|
378
|
-
case
|
|
398
|
+
return [3 /*break*/, 16];
|
|
399
|
+
case 16: return [2 /*return*/];
|
|
379
400
|
}
|
|
380
401
|
});
|
|
381
402
|
});
|
|
@@ -422,7 +443,7 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
422
443
|
purchaseID: purchase.transactionId || '',
|
|
423
444
|
transactionDate: purchase.transactionDate || '',
|
|
424
445
|
status: react_native_1.Platform.select({
|
|
425
|
-
ios: purchase.transactionStateIOS,
|
|
446
|
+
ios: purchase.transactionStateIOS,
|
|
426
447
|
android: purchase.purchaseStateAndroid,
|
|
427
448
|
}),
|
|
428
449
|
verificationData: {
|
|
@@ -440,31 +461,53 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
440
461
|
productCurrencyCode: product.currency,
|
|
441
462
|
};
|
|
442
463
|
};
|
|
464
|
+
GoMarketMe.prototype.serializeSubscriptionDetails = function (subscription) {
|
|
465
|
+
return {
|
|
466
|
+
productID: subscription.productId,
|
|
467
|
+
productTitle: subscription.title,
|
|
468
|
+
productDescription: subscription.description,
|
|
469
|
+
productPrice: subscription.price,
|
|
470
|
+
productRawPrice: subscription.price,
|
|
471
|
+
productCurrencyCode: subscription.currency,
|
|
472
|
+
};
|
|
473
|
+
};
|
|
443
474
|
GoMarketMe.prototype.markSDKAsInitialized = function () {
|
|
444
475
|
return __awaiter(this, void 0, void 0, function () {
|
|
476
|
+
var e_6;
|
|
445
477
|
return __generator(this, function (_a) {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
478
|
+
switch (_a.label) {
|
|
479
|
+
case 0:
|
|
480
|
+
_a.trys.push([0, 2, , 3]);
|
|
481
|
+
return [4 /*yield*/, async_storage_1.default.setItem(this.sdkInitializedKey, 'true')];
|
|
482
|
+
case 1:
|
|
483
|
+
_a.sent();
|
|
484
|
+
return [2 /*return*/, true];
|
|
485
|
+
case 2:
|
|
486
|
+
e_6 = _a.sent();
|
|
487
|
+
console.error('Failed to save SDK initialization:', e_6);
|
|
488
|
+
return [2 /*return*/, false];
|
|
489
|
+
case 3: return [2 /*return*/];
|
|
490
|
+
}
|
|
454
491
|
});
|
|
455
492
|
});
|
|
456
493
|
};
|
|
457
494
|
GoMarketMe.prototype.isSDKInitialized = function () {
|
|
458
495
|
return __awaiter(this, void 0, void 0, function () {
|
|
496
|
+
var value, e_7;
|
|
459
497
|
return __generator(this, function (_a) {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
498
|
+
switch (_a.label) {
|
|
499
|
+
case 0:
|
|
500
|
+
_a.trys.push([0, 2, , 3]);
|
|
501
|
+
return [4 /*yield*/, async_storage_1.default.getItem(this.sdkInitializedKey)];
|
|
502
|
+
case 1:
|
|
503
|
+
value = _a.sent();
|
|
504
|
+
return [2 /*return*/, value === 'true'];
|
|
505
|
+
case 2:
|
|
506
|
+
e_7 = _a.sent();
|
|
507
|
+
console.error('Failed to load SDK initialization:', e_7);
|
|
508
|
+
return [2 /*return*/, false];
|
|
509
|
+
case 3: return [2 /*return*/];
|
|
510
|
+
}
|
|
468
511
|
});
|
|
469
512
|
});
|
|
470
513
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gomarketme-react-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
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,6 +1,8 @@
|
|
|
1
1
|
import { Platform, Dimensions, PixelRatio } from 'react-native';
|
|
2
2
|
import DeviceInfo from 'react-native-device-info';
|
|
3
|
-
import
|
|
3
|
+
import getUserLocale from 'get-user-locale'
|
|
4
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
5
|
+
import InAppPurchase, { Purchase, Product, Subscription } from 'react-native-iap';
|
|
4
6
|
import axios from 'axios';
|
|
5
7
|
|
|
6
8
|
class GoMarketMe {
|
|
@@ -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,13 +183,20 @@ 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);
|
|
176
190
|
}
|
|
177
191
|
} else {
|
|
178
|
-
await
|
|
192
|
+
const products = await InAppPurchase.getSubscriptions(productIds);
|
|
193
|
+
if (products.length > 0) {
|
|
194
|
+
for (const product of products) {
|
|
195
|
+
await this.sendEventToServer(JSON.stringify(this.serializeSubscriptionDetails(product)), 'product', apiKey);
|
|
196
|
+
}
|
|
197
|
+
} else {
|
|
198
|
+
await this.sendEventToServer(JSON.stringify({ notFoundIDs: productIds.join(',') }), 'product', apiKey);
|
|
199
|
+
}
|
|
179
200
|
}
|
|
180
201
|
} catch (e) {
|
|
181
202
|
console.error('Error fetching products:', e);
|
|
@@ -231,26 +252,35 @@ class GoMarketMe {
|
|
|
231
252
|
};
|
|
232
253
|
}
|
|
233
254
|
|
|
255
|
+
private serializeSubscriptionDetails(subscription: Subscription): any {
|
|
256
|
+
return {
|
|
257
|
+
productID: subscription.productId,
|
|
258
|
+
productTitle: subscription.title,
|
|
259
|
+
productDescription: subscription.description,
|
|
260
|
+
productPrice: subscription.price,
|
|
261
|
+
productRawPrice: subscription.price,
|
|
262
|
+
productCurrencyCode: subscription.currency,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
234
266
|
private async markSDKAsInitialized(): Promise<boolean> {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
return true;
|
|
267
|
+
try {
|
|
268
|
+
await AsyncStorage.setItem(this.sdkInitializedKey, 'true');
|
|
269
|
+
return true;
|
|
270
|
+
} catch (e) {
|
|
271
|
+
console.error('Failed to save SDK initialization:', e);
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
243
274
|
}
|
|
244
275
|
|
|
245
276
|
private async isSDKInitialized(): Promise<boolean> {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
return false;
|
|
277
|
+
try {
|
|
278
|
+
const value = await AsyncStorage.getItem(this.sdkInitializedKey);
|
|
279
|
+
return value === 'true';
|
|
280
|
+
} catch (e) {
|
|
281
|
+
console.error('Failed to load SDK initialization:', e);
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
254
284
|
}
|
|
255
285
|
}
|
|
256
286
|
|