gomarketme-react-native 1.1.0 → 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 +1 -0
- package/dist/index.js +43 -16
- package/package.json +1 -1
- package/src/index.tsx +20 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -348,38 +348,55 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
348
348
|
};
|
|
349
349
|
GoMarketMe.prototype.fetchPurchaseProducts = function (productIds, apiKey) {
|
|
350
350
|
return __awaiter(this, void 0, void 0, function () {
|
|
351
|
-
var products, _i, products_1, product, e_4;
|
|
352
|
-
return __generator(this, function (
|
|
353
|
-
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) {
|
|
354
354
|
case 0:
|
|
355
|
-
|
|
355
|
+
_b.trys.push([0, 15, , 16]);
|
|
356
356
|
return [4 /*yield*/, react_native_iap_1.default.getProducts(productIds)];
|
|
357
357
|
case 1:
|
|
358
|
-
products =
|
|
358
|
+
products = _b.sent();
|
|
359
359
|
if (!(products.length > 0)) return [3 /*break*/, 6];
|
|
360
360
|
_i = 0, products_1 = products;
|
|
361
|
-
|
|
361
|
+
_b.label = 2;
|
|
362
362
|
case 2:
|
|
363
363
|
if (!(_i < products_1.length)) return [3 /*break*/, 5];
|
|
364
364
|
product = products_1[_i];
|
|
365
365
|
return [4 /*yield*/, this.sendEventToServer(JSON.stringify(this.serializeProductDetails(product)), 'product', apiKey)];
|
|
366
366
|
case 3:
|
|
367
|
-
|
|
368
|
-
|
|
367
|
+
_b.sent();
|
|
368
|
+
_b.label = 4;
|
|
369
369
|
case 4:
|
|
370
370
|
_i++;
|
|
371
371
|
return [3 /*break*/, 2];
|
|
372
|
-
case 5: return [3 /*break*/,
|
|
373
|
-
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)];
|
|
374
374
|
case 7:
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
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)];
|
|
378
383
|
case 9:
|
|
379
|
-
|
|
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();
|
|
380
397
|
console.error('Error fetching products:', e_4);
|
|
381
|
-
return [3 /*break*/,
|
|
382
|
-
case
|
|
398
|
+
return [3 /*break*/, 16];
|
|
399
|
+
case 16: return [2 /*return*/];
|
|
383
400
|
}
|
|
384
401
|
});
|
|
385
402
|
});
|
|
@@ -444,6 +461,16 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
444
461
|
productCurrencyCode: product.currency,
|
|
445
462
|
};
|
|
446
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
|
+
};
|
|
447
474
|
GoMarketMe.prototype.markSDKAsInitialized = function () {
|
|
448
475
|
return __awaiter(this, void 0, void 0, function () {
|
|
449
476
|
var e_6;
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { Platform, Dimensions, PixelRatio } from 'react-native';
|
|
|
2
2
|
import DeviceInfo from 'react-native-device-info';
|
|
3
3
|
import getUserLocale from 'get-user-locale'
|
|
4
4
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
5
|
-
import InAppPurchase, { Purchase, Product,
|
|
5
|
+
import InAppPurchase, { Purchase, Product, Subscription } from 'react-native-iap';
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
|
|
8
8
|
class GoMarketMe {
|
|
@@ -189,7 +189,14 @@ class GoMarketMe {
|
|
|
189
189
|
await this.sendEventToServer(JSON.stringify(this.serializeProductDetails(product)), 'product', apiKey);
|
|
190
190
|
}
|
|
191
191
|
} else {
|
|
192
|
-
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
|
+
}
|
|
193
200
|
}
|
|
194
201
|
} catch (e) {
|
|
195
202
|
console.error('Error fetching products:', e);
|
|
@@ -245,6 +252,17 @@ class GoMarketMe {
|
|
|
245
252
|
};
|
|
246
253
|
}
|
|
247
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
|
+
|
|
248
266
|
private async markSDKAsInitialized(): Promise<boolean> {
|
|
249
267
|
try {
|
|
250
268
|
await AsyncStorage.setItem(this.sdkInitializedKey, 'true');
|