apps-sdk 1.0.55 → 1.0.56
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/config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apps-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.56",
|
|
4
4
|
"description": "Apps SDK",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,8 +24,10 @@
|
|
|
24
24
|
"react-native": "^0.73.2",
|
|
25
25
|
"react-native-adjust": "^4.37.1",
|
|
26
26
|
"react-native-btr": "^2.2.1",
|
|
27
|
+
"react-native-device-info": "^10.13.1",
|
|
27
28
|
"react-native-iap": "^12.12.2",
|
|
28
|
-
"react-native-webview": "^13.8.1"
|
|
29
|
+
"react-native-webview": "^13.8.1",
|
|
30
|
+
"semver": "^7.6.0"
|
|
29
31
|
},
|
|
30
32
|
"types": "./types/index.d.ts"
|
|
31
33
|
}
|
|
@@ -72,7 +72,7 @@ class PayWall extends React.Component {
|
|
|
72
72
|
eventClickSubscribe = (data) => {
|
|
73
73
|
Networking.sendEvent('action', 'cta');
|
|
74
74
|
if (this.paywallData && this.paywallData.products_id && this.paywallData.products_id.length > 0) {
|
|
75
|
-
let subscribed = PayWallLogic.executePurchase(this.paywallData.products_id[0], this.hideSpinner).then((subscribed) => {
|
|
75
|
+
let subscribed = PayWallLogic.executePurchase(this.paywallData.products_id[0], this.hideSpinner, this.hidePayWall).then((subscribed) => {
|
|
76
76
|
console.log('subscription result: ',subscribed);
|
|
77
77
|
if (subscribed) {
|
|
78
78
|
this.props.onSubscribe();
|
|
@@ -96,7 +96,11 @@ class PayWall extends React.Component {
|
|
|
96
96
|
console.log('SDK setHideLoaderAppquiles',event);
|
|
97
97
|
this.webviewRef.current.injectJavaScript(
|
|
98
98
|
`Appquiles.emitAppEvent(${JSON.stringify(event)});$('.spinner').hide();`
|
|
99
|
-
)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
hidePayWall = () => {
|
|
103
|
+
this.props.onClose();
|
|
100
104
|
}
|
|
101
105
|
// --------------------------------------- Eventos ---------------------------------------
|
|
102
106
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as config from '../../config';
|
|
2
2
|
import NetInfo from "@react-native-community/netinfo";
|
|
3
|
+
import DeviceInfo from 'react-native-device-info';
|
|
3
4
|
import { default as storage } from './Storage';
|
|
4
5
|
import Session from './Session';
|
|
5
6
|
import AdJust from './AdJust';
|
|
6
7
|
import CryptoES from "crypto-es";
|
|
8
|
+
import semver from 'semver';
|
|
7
9
|
|
|
8
10
|
class Networking {
|
|
9
11
|
constructor() {
|
|
@@ -29,6 +31,7 @@ class Networking {
|
|
|
29
31
|
this.setEvents(initData.data.attribution);
|
|
30
32
|
this.setPayWallData(initData);
|
|
31
33
|
this.checkSubscription();
|
|
34
|
+
this.setForcedUpdate(initData);
|
|
32
35
|
}
|
|
33
36
|
} catch (error) {
|
|
34
37
|
console.error(error);
|
|
@@ -150,6 +153,11 @@ class Networking {
|
|
|
150
153
|
}
|
|
151
154
|
}
|
|
152
155
|
|
|
156
|
+
setForcedUpdate = (data) => {
|
|
157
|
+
const currentVersion = DeviceInfo.getVersion();
|
|
158
|
+
return data.update_state === 'force' && semver.lt(currentVersion, data.release);
|
|
159
|
+
}
|
|
160
|
+
|
|
153
161
|
setEvents(events) {
|
|
154
162
|
events && (config.EVENTS = events);
|
|
155
163
|
}
|
|
@@ -91,7 +91,7 @@ class PayWallLogic {
|
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
executePurchase = async (productID, hideLoaderCallback) => {
|
|
94
|
+
executePurchase = async (productID, hideLoaderCallback, hidePayWallCallback) => {
|
|
95
95
|
let subscribed = false;
|
|
96
96
|
try {
|
|
97
97
|
const subscriptionTemplates = await getSubscriptions({skus: [productID]});
|
|
@@ -100,22 +100,21 @@ class PayWallLogic {
|
|
|
100
100
|
const subscription = subscriptionTemplates[0];
|
|
101
101
|
const sku = subscription.productId;
|
|
102
102
|
const offerToken = Platform.OS === 'android' ? subscription.subscriptionOfferDetails[0].offerToken : false;
|
|
103
|
-
if (hideLoaderCallback) {
|
|
104
|
-
setTimeout(() => {
|
|
105
|
-
hideLoaderCallback();
|
|
106
|
-
}, 15000);
|
|
107
|
-
}
|
|
108
103
|
await requestSubscription({
|
|
109
104
|
sku,
|
|
110
105
|
...(offerToken && {subscriptionOffers: [{sku, offerToken}]}),
|
|
111
106
|
});
|
|
112
|
-
console.log('paso 2');
|
|
113
107
|
subscribed = true;
|
|
108
|
+
if (hidePayWallCallback) {
|
|
109
|
+
hidePayWallCallback();
|
|
110
|
+
}
|
|
114
111
|
}
|
|
115
112
|
} catch (err) {
|
|
116
113
|
console.log(err.code, err.message);
|
|
117
114
|
}
|
|
118
|
-
|
|
115
|
+
if (hideLoaderCallback) {
|
|
116
|
+
hideLoaderCallback();
|
|
117
|
+
}
|
|
119
118
|
return subscribed;
|
|
120
119
|
};
|
|
121
120
|
|
package/src/libraries/Session.js
CHANGED
|
@@ -13,6 +13,7 @@ class Session {
|
|
|
13
13
|
isSubscribed = false;
|
|
14
14
|
subscriptionData = {};
|
|
15
15
|
isDevUser = false;
|
|
16
|
+
forcedUpdate = false;
|
|
16
17
|
|
|
17
18
|
init = async () => {
|
|
18
19
|
config.DEBUG_MODE && console.debug("init");
|
|
@@ -171,6 +172,10 @@ class Session {
|
|
|
171
172
|
config.DEBUG_MODE && console.debug("checkSubscription24h - Not 24h yet");
|
|
172
173
|
}
|
|
173
174
|
}
|
|
175
|
+
|
|
176
|
+
isForcedUpdate = () => {
|
|
177
|
+
return config.FORCED_UPDATE;
|
|
178
|
+
}
|
|
174
179
|
}
|
|
175
180
|
|
|
176
181
|
export default new Session();
|