apps-sdk 1.0.44 → 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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import {NotificationsPush, Networking, Storage, Session, Utils, PayWallLogic} from "./src/libraries";
1
+ import {NotificationsPush, Networking, Storage, Session, Utils, PayWallLogic, Rating} from "./src/libraries";
2
2
  import PayWall from "./src/components/PayWall";
3
3
 
4
4
  class AppsSDK {
@@ -18,6 +18,7 @@ export default {
18
18
  storage: Storage,
19
19
  session: Session,
20
20
  utils: Utils,
21
+ rating: Rating,
21
22
  paywallLogic: PayWallLogic,
22
23
  paywall: PayWall,
23
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,7 +21,8 @@
21
21
  "react-native": "^0.73.2",
22
22
  "react-native-btr": "^2.2.1",
23
23
  "react-native-iap": "^12.12.2",
24
- "react-native-webview": "^13.8.1"
24
+ "react-native-webview": "^13.8.1",
25
+ "expo-store-review": "~6.8.3"
25
26
  },
26
27
  "types": "./types/index.d.ts"
27
28
  }
@@ -59,7 +59,7 @@ class PayWall extends React.Component {
59
59
  eventClickSubscribe = (data) => {
60
60
  Networking.sendEvent('action', 'cta');
61
61
  if (this.paywallData && this.paywallData.products_id && this.paywallData.products_id.length > 0) {
62
- let subscribed = this.executePurchase(this.paywallData.products_id[0]);
62
+ let subscribed = PayWallLogic.executePurchase(this.paywallData.products_id[0]);
63
63
  console.log('subscribed',subscribed)
64
64
  }
65
65
  setTimeout(() => {
@@ -0,0 +1,36 @@
1
+ import * as StoreReview from 'expo-store-review';
2
+ import Storage from './Storage';
3
+
4
+ const REVIEW_INTERVAL = 1000 * 60 * 60 * 24 * 3; // 3 días
5
+ class Rating {
6
+ showRatingDialog = async () => {
7
+ try {
8
+ if (await this.requestReviewIfNeeded()) {
9
+ if (await StoreReview.hasAction()) {
10
+ if (await StoreReview.isAvailableAsync()) {
11
+ return await StoreReview.requestReview();
12
+ }
13
+ }
14
+ } else {
15
+ console.log("Rating requestReviewIfNeeded not needed");
16
+ }
17
+ } catch (error) {
18
+ console.log("Error en requestReview", error);
19
+ }
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
+ }
34
+ }
35
+
36
+ export default new Rating();
@@ -3,4 +3,5 @@ export { default as Networking } from './Networking';
3
3
  export { default as Storage } from './Storage';
4
4
  export { default as Session } from './Session';
5
5
  export { default as Utils } from './Utils';
6
+ export { default as Rating } from './Rating';
6
7
  export { default as PayWallLogic } from './PayWallLogic';
package/types/index.d.ts CHANGED
@@ -82,6 +82,10 @@ declare module 'apps-sdk' {
82
82
  isBase64Image(str: string): boolean;
83
83
  }
84
84
 
85
+ export class Rating {
86
+ showRatingDialog(): Promise<void>;
87
+ }
88
+
85
89
  export class NotificationsPush {
86
90
  initialize(): Promise<void>;
87
91
  registerForPushNotificationsAsync(): Promise<string>;
@@ -112,6 +116,7 @@ declare module 'apps-sdk' {
112
116
  session: Session;
113
117
  utils: Utils;
114
118
  paywall: PayWall;
119
+ rating: Rating;
115
120
  paywallLogic: PayWallLogic;
116
121
  }
117
122