apps-sdk 1.0.45 → 1.0.46

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.0.45",
3
+ "version": "1.0.46",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,17 +1,36 @@
1
1
  import * as StoreReview from 'expo-store-review';
2
+ import Storage from './Storage';
2
3
 
4
+ const REVIEW_INTERVAL = 1000 * 60 * 60 * 24 * 3; // 3 días
3
5
  class Rating {
4
6
  showRatingDialog = async () => {
5
7
  try {
6
- if (await StoreReview.hasAction()) {
7
- if (await StoreReview.isAvailableAsync()) {
8
- return await StoreReview.requestReview();
8
+ if (await this.requestReviewIfNeeded()) {
9
+ if (await StoreReview.hasAction()) {
10
+ if (await StoreReview.isAvailableAsync()) {
11
+ return await StoreReview.requestReview();
12
+ }
9
13
  }
14
+ } else {
15
+ console.log("Rating requestReviewIfNeeded not needed");
10
16
  }
11
17
  } catch (error) {
12
18
  console.log("Error en requestReview", error);
13
19
  }
14
20
  }
21
+
22
+ requestReviewIfNeeded = async () => {
23
+ const lastReviewRequestString = await Storage.getData('lastReviewRequest');
24
+ const lastReviewRequest = lastReviewRequestString ? Number(lastReviewRequestString) : 0;
25
+ const now = Date.now();
26
+ if (now - lastReviewRequest > REVIEW_INTERVAL) {
27
+ const available = await StoreReview.isAvailableAsync();
28
+ if (available) {
29
+ await StoreReview.requestReview();
30
+ await Storage.storeData('lastReviewRequest', now.toString());
31
+ }
32
+ }
33
+ }
15
34
  }
16
35
 
17
36
  export default new Rating();
package/types/index.d.ts CHANGED
@@ -116,6 +116,7 @@ declare module 'apps-sdk' {
116
116
  session: Session;
117
117
  utils: Utils;
118
118
  paywall: PayWall;
119
+ rating: Rating;
119
120
  paywallLogic: PayWallLogic;
120
121
  }
121
122