apps-sdk 1.0.41 → 1.0.43
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 +3 -1
- package/package.json +1 -1
- package/src/components/PayWall.js +106 -0
- package/src/libraries/{PayWall.js → PayWallLogic.js} +3 -101
- package/src/libraries/index.js +1 -1
- package/types/index.d.ts +4 -1
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {NotificationsPush, Networking, Storage, Session, Utils,
|
|
1
|
+
import {NotificationsPush, Networking, Storage, Session, Utils, PayWallLogic} from "./src/libraries";
|
|
2
|
+
import PayWall from "./src/components/PayWall";
|
|
2
3
|
|
|
3
4
|
class AppsSDK {
|
|
4
5
|
initializePushNotifications = async() => {
|
|
@@ -17,5 +18,6 @@ export default {
|
|
|
17
18
|
storage: Storage,
|
|
18
19
|
session: Session,
|
|
19
20
|
utils: Utils,
|
|
21
|
+
paywallLogic: PayWallLogic,
|
|
20
22
|
paywall: PayWall,
|
|
21
23
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {BottomSheet} from 'react-native-btr';
|
|
3
|
+
import {WebView} from 'react-native-webview';
|
|
4
|
+
import {View} from "react-native";
|
|
5
|
+
import Utils from "../libraries/Utils";
|
|
6
|
+
import Networking from "../libraries/Networking";
|
|
7
|
+
import PayWallLogic from "../libraries/PayWallLogic";
|
|
8
|
+
import * as config from "../../config";
|
|
9
|
+
|
|
10
|
+
class PayWall extends React.Component {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
this.webviewRef = React.createRef();
|
|
14
|
+
this.paywallData = {};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getURL = () => {
|
|
18
|
+
// CP de prueba
|
|
19
|
+
return "https://backend.ailandsapp.com/payment-card/ZLp_slash_QSy94h9aKdNJWvvvkE8dkHSyeiTGRxsZVQAaiiYveh2jTjeZVJnnIZ0WVKTgiRoAkEoVrB2leXjt_slash_l2g2MtLKRa_slash_30mL6tMu0L9IJxY=?dsn_id=6274";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getPayWallJS = () => {
|
|
23
|
+
// return "window.subInfoInterval = setInterval(() => window.Appquiles && Appquiles.setSubscriptionPlans(" + JSON.stringify(information.subsPlansInfo) + "), 300);" : '';
|
|
24
|
+
return "window.subInfoInterval = setInterval(() => window.Appquiles, 300);";
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getPayWallData = (type, keyword) => {
|
|
29
|
+
if (!config.PAYWALL_DATA[type] || !config.PAYWALL_DATA[type][keyword]) {
|
|
30
|
+
console.log('No se encontraron datos para el paywall.');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
console.log('PayWallData: ', JSON.stringify(config.PAYWALL_DATA[type][keyword]));
|
|
34
|
+
this.paywallData = config.PAYWALL_DATA[type][keyword];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
handleMessage = (message) => {
|
|
38
|
+
const data = JSON.parse(message.nativeEvent.data);
|
|
39
|
+
const event = "event" + Utils.capitalize(data.query);
|
|
40
|
+
if (typeof this[event] === 'function') {
|
|
41
|
+
this[event](data);
|
|
42
|
+
} else {
|
|
43
|
+
console.log(`El método ${event} no existe en la clase.`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
componentDidUpdate(prevProps) {
|
|
48
|
+
if (this.props.visible && !prevProps.visible) {
|
|
49
|
+
this.webviewRef.current.injectJavaScript(this.getPayWallJS());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// --------------------------------------- Eventos ---------------------------------------
|
|
54
|
+
eventClickClose = (data) => {
|
|
55
|
+
Networking.sendEvent('action', 'continue_free');
|
|
56
|
+
this.props.onClose();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
eventClickSubscribe = (data) => {
|
|
60
|
+
Networking.sendEvent('action', 'cta');
|
|
61
|
+
if (this.paywallData && this.paywallData.products_id && this.paywallData.products_id.length > 0) {
|
|
62
|
+
let subscribed = this.executePurchase(this.paywallData.products_id[0]);
|
|
63
|
+
console.log('subscribed',subscribed)
|
|
64
|
+
}
|
|
65
|
+
setTimeout(() => {
|
|
66
|
+
this.hideSpinner();
|
|
67
|
+
}, 3000);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
hideSpinner = () => {
|
|
71
|
+
const event = {
|
|
72
|
+
event: 'hideLoader',
|
|
73
|
+
value: {
|
|
74
|
+
status: true,
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
console.log('SDK setHideLoaderAppquiles',event);
|
|
78
|
+
this.webviewRef.current.injectJavaScript(
|
|
79
|
+
`Appquiles.emitAppEvent(${JSON.stringify(event)});$('.spinner').hide();`
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
// --------------------------------------- Eventos ---------------------------------------
|
|
83
|
+
|
|
84
|
+
render() {
|
|
85
|
+
const { visible, onClose, type, keyword } = this.props;
|
|
86
|
+
this.getPayWallData(type, keyword);
|
|
87
|
+
return (
|
|
88
|
+
<BottomSheet visible={visible} onBackButtonPress={onClose} onBackdropPress={onClose}>
|
|
89
|
+
<View style={styles.bottomNavigationView}>
|
|
90
|
+
<WebView style={{flex:1}} source={{ uri: this.paywallData.url }} javaScriptEnabled ref={this.webviewRef} onMessage={this.handleMessage} onError={(err) => {console.log('Error al cargar webview:',err)}} injectedJavaScript={this.getPayWallJS()}/>
|
|
91
|
+
</View>
|
|
92
|
+
</BottomSheet>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const styles = {
|
|
98
|
+
bottomNavigationView: {
|
|
99
|
+
backgroundColor: '#000',
|
|
100
|
+
width: '100%',
|
|
101
|
+
height: '100%',
|
|
102
|
+
paddingTop: 35,
|
|
103
|
+
},
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export default PayWall;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {WebView} from 'react-native-webview';
|
|
4
|
-
import {Platform, View} from "react-native";
|
|
5
|
-
import Utils from "./Utils";
|
|
2
|
+
import {Platform} from "react-native";
|
|
6
3
|
import Networking from "./Networking";
|
|
7
4
|
import Session from "./Session";
|
|
8
|
-
import * as config from "../../config";
|
|
9
5
|
import {
|
|
10
6
|
finishTransaction,
|
|
11
7
|
flushFailedPurchasesCachedAsPendingAndroid,
|
|
@@ -14,56 +10,11 @@ import {
|
|
|
14
10
|
purchaseErrorListener,
|
|
15
11
|
purchaseUpdatedListener, requestSubscription,
|
|
16
12
|
} from 'react-native-iap';
|
|
17
|
-
import Constants from "expo-constants";
|
|
18
13
|
|
|
19
|
-
class
|
|
14
|
+
class PayWallLogic {
|
|
20
15
|
purchaseUpdateSubscription;
|
|
21
16
|
purchaseErrorSubscription;
|
|
22
17
|
|
|
23
|
-
constructor(props) {
|
|
24
|
-
super(props);
|
|
25
|
-
this.webviewRef = React.createRef();
|
|
26
|
-
this.paywallData = {};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
getURL = () => {
|
|
30
|
-
// CP de prueba
|
|
31
|
-
return "https://backend.ailandsapp.com/payment-card/ZLp_slash_QSy94h9aKdNJWvvvkE8dkHSyeiTGRxsZVQAaiiYveh2jTjeZVJnnIZ0WVKTgiRoAkEoVrB2leXjt_slash_l2g2MtLKRa_slash_30mL6tMu0L9IJxY=?dsn_id=6274";
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
getPayWallJS = () => {
|
|
35
|
-
// return "window.subInfoInterval = setInterval(() => window.Appquiles && Appquiles.setSubscriptionPlans(" + JSON.stringify(information.subsPlansInfo) + "), 300);" : '';
|
|
36
|
-
return "window.subInfoInterval = setInterval(() => window.Appquiles, 300);";
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
getPayWallData = (type, keyword) => {
|
|
41
|
-
if (!config.PAYWALL_DATA[type] || !config.PAYWALL_DATA[type][keyword]) {
|
|
42
|
-
console.log('No se encontraron datos para el paywall.');
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
console.log('PayWallData: ', JSON.stringify(config.PAYWALL_DATA[type][keyword]));
|
|
46
|
-
this.paywallData = config.PAYWALL_DATA[type][keyword];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
handleMessage = (message) => {
|
|
50
|
-
const data = JSON.parse(message.nativeEvent.data);
|
|
51
|
-
const event = "event" + Utils.capitalize(data.query);
|
|
52
|
-
if (typeof this[event] === 'function') {
|
|
53
|
-
this[event](data);
|
|
54
|
-
} else {
|
|
55
|
-
console.log(`El método ${event} no existe en la clase.`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
componentDidUpdate(prevProps) {
|
|
60
|
-
if (this.props.visible && !prevProps.visible) {
|
|
61
|
-
this.webviewRef.current.injectJavaScript(this.getPayWallJS());
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// --------------------------------- Funciones para Pago ---------------------------------------
|
|
66
|
-
|
|
67
18
|
async initializePayWall() {
|
|
68
19
|
initConnection().then(async () => {
|
|
69
20
|
|
|
@@ -144,55 +95,6 @@ class PayWall extends React.Component {
|
|
|
144
95
|
}
|
|
145
96
|
return subscribe;
|
|
146
97
|
};
|
|
147
|
-
|
|
148
|
-
// --------------------------------------- Eventos ---------------------------------------
|
|
149
|
-
eventClickClose = (data) => {
|
|
150
|
-
Networking.sendEvent('action', 'continue_free');
|
|
151
|
-
this.props.onClose();
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
eventClickSubscribe = (data) => {
|
|
155
|
-
console.log(data);
|
|
156
|
-
Networking.sendEvent('action', 'cta');
|
|
157
|
-
setTimeout(() => {
|
|
158
|
-
this.hideSpinner();
|
|
159
|
-
}, 3000);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
hideSpinner = () => {
|
|
163
|
-
const event = {
|
|
164
|
-
event: 'hideLoader',
|
|
165
|
-
value: {
|
|
166
|
-
status: true,
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
console.log('SDK setHideLoaderAppquiles',event);
|
|
170
|
-
this.webviewRef.current.injectJavaScript(
|
|
171
|
-
`Appquiles.emitAppEvent(${JSON.stringify(event)});$('.spinner').hide();`
|
|
172
|
-
)
|
|
173
|
-
}
|
|
174
|
-
// --------------------------------------- Eventos ---------------------------------------
|
|
175
|
-
|
|
176
|
-
render() {
|
|
177
|
-
const { visible, onClose, type, keyword } = this.props;
|
|
178
|
-
this.getPayWallData(type, keyword);
|
|
179
|
-
return (
|
|
180
|
-
<BottomSheet visible={visible} onBackButtonPress={onClose} onBackdropPress={onClose}>
|
|
181
|
-
<View style={styles.bottomNavigationView}>
|
|
182
|
-
<WebView style={{flex:1}} source={{ uri: this.paywallData.url }} javaScriptEnabled ref={this.webviewRef} onMessage={this.handleMessage} onError={(err) => {console.log('Error al cargar webview:',err)}} injectedJavaScript={this.getPayWallJS()}/>
|
|
183
|
-
</View>
|
|
184
|
-
</BottomSheet>
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const styles = {
|
|
190
|
-
bottomNavigationView: {
|
|
191
|
-
backgroundColor: '#000',
|
|
192
|
-
width: '100%',
|
|
193
|
-
height: '100%',
|
|
194
|
-
paddingTop: 35,
|
|
195
|
-
},
|
|
196
98
|
}
|
|
197
99
|
|
|
198
|
-
export default
|
|
100
|
+
export default new PayWallLogic();
|
package/src/libraries/index.js
CHANGED
|
@@ -3,4 +3,4 @@ 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
|
|
6
|
+
export { default as PayWallLogic } from './PayWallLogic';
|
package/types/index.d.ts
CHANGED
|
@@ -94,7 +94,9 @@ declare module 'apps-sdk' {
|
|
|
94
94
|
keyword: string;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
export class PayWall {
|
|
97
|
+
export class PayWall extends Component<PayWallProps, {}> {}
|
|
98
|
+
|
|
99
|
+
export class PayWallLogic {
|
|
98
100
|
initializePayWall(): Promise<void>;
|
|
99
101
|
executePurchase(productID: string): Promise<void>;
|
|
100
102
|
}
|
|
@@ -110,6 +112,7 @@ declare module 'apps-sdk' {
|
|
|
110
112
|
session: Session;
|
|
111
113
|
utils: Utils;
|
|
112
114
|
paywall: PayWall;
|
|
115
|
+
paywallLogic: PayWallLogic;
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
const Core: AppsSDK;
|