apps-sdk 1.0.34 → 1.0.36
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 +12 -6
- package/index.js +0 -1
- package/package.json +1 -1
- package/src/libraries/Networking.js +32 -1
- package/src/libraries/PayWall.js +47 -4
- package/src/libraries/Storage.js +2 -2
- package/types/index.d.ts +4 -3
package/config.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
export var ENDPOINTS = {
|
|
2
|
-
INIT : 'https://
|
|
3
|
-
NOTIFICATION_TOKEN: 'https://
|
|
4
|
-
TRACKING: 'https://
|
|
5
|
-
GET_USER_ID: 'https://
|
|
6
|
-
CHECK_SUBSCRIPTION: 'https://
|
|
7
|
-
SET_ATTRIBUTION: 'https://
|
|
2
|
+
INIT : 'https://backend.ailandsapp.com/v6/init',
|
|
3
|
+
NOTIFICATION_TOKEN: 'https://backend.ailandsapp.com/user/set_expo_id',
|
|
4
|
+
TRACKING: 'https://backend.ailandsapp.com/v3/log-event',
|
|
5
|
+
GET_USER_ID: 'https://backend.ailandsapp.com/user/generate_public_id',
|
|
6
|
+
CHECK_SUBSCRIPTION: 'https://backend.ailandsapp.com/create-sub',
|
|
7
|
+
SET_ATTRIBUTION: 'https://backend.ailandsapp.com/user/set_attribution_data',
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export var EVENTS = {}
|
|
11
11
|
|
|
12
|
+
export var PAYWALL_DATA = {
|
|
13
|
+
actions: {},
|
|
14
|
+
scenes: {},
|
|
15
|
+
others: {}
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
export const EVENT_TYPES = {
|
|
13
19
|
ACTION: 'action',
|
|
14
20
|
SCENE: 'scene',
|
package/index.js
CHANGED
|
@@ -6,7 +6,6 @@ class AppsSDK {
|
|
|
6
6
|
|
|
7
7
|
return NotificationsPush.registerForPushNotificationsAsync().then(async (expoToken) => {
|
|
8
8
|
return expoToken
|
|
9
|
-
// const setExpoToken = await Networking.setExpoToken({expo_id : expoToken, user_id : Session._info.user_id, ...Session._info} )
|
|
10
9
|
})
|
|
11
10
|
}
|
|
12
11
|
}
|
package/package.json
CHANGED
|
@@ -44,9 +44,10 @@ class Networking {
|
|
|
44
44
|
try {
|
|
45
45
|
let initData = await this.request(config.ENDPOINTS.INIT);
|
|
46
46
|
if (initData) {
|
|
47
|
-
config.DEBUG_MODE && console.debug("initData", initData);
|
|
47
|
+
config.DEBUG_MODE && console.debug("initData", JSON.stringify(initData));
|
|
48
48
|
this.setEndpoints(initData.data.domains);
|
|
49
49
|
this.setEvents(initData.data.attribution);
|
|
50
|
+
this.setPayWallData(initData);
|
|
50
51
|
}
|
|
51
52
|
} catch (error) {
|
|
52
53
|
console.error(error);
|
|
@@ -151,6 +152,36 @@ class Networking {
|
|
|
151
152
|
events && (config.EVENTS = events);
|
|
152
153
|
}
|
|
153
154
|
|
|
155
|
+
setPayWallData(data) {
|
|
156
|
+
let result = {
|
|
157
|
+
actions: {},
|
|
158
|
+
scenes: {},
|
|
159
|
+
others: {}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
if (data && data.data && data.data.purchase) {
|
|
163
|
+
if (data.data.purchase.actions) {
|
|
164
|
+
data.data.purchase.actions.forEach(action => {
|
|
165
|
+
result.actions[action.identifier] = action;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
if (data.data.purchase.scenes) {
|
|
169
|
+
data.data.purchase.scenes.forEach(scene => {
|
|
170
|
+
result.scenes[scene.identifier] = scene;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
if (data.data.purchase.others) {
|
|
174
|
+
data.data.purchase.others.forEach(other => {
|
|
175
|
+
result.others[other.identifier] = other;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (result) {
|
|
181
|
+
config.PAYWALL_DATA = result;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
154
185
|
sendEvent = async (eventType, eventKeyword, eventData={}) => {
|
|
155
186
|
config.DEBUG_MODE && console.debug("sendEvent", eventType, eventKeyword, eventData);
|
|
156
187
|
try {
|
package/src/libraries/PayWall.js
CHANGED
|
@@ -3,19 +3,34 @@ import { BottomSheet } from 'react-native-btr';
|
|
|
3
3
|
import { WebView } from 'react-native-webview';
|
|
4
4
|
import { View } from "react-native";
|
|
5
5
|
import Utils from "./Utils";
|
|
6
|
+
import Networking from "./Networking";
|
|
7
|
+
import Session from "./Session";
|
|
8
|
+
import * as config from "../../config";
|
|
6
9
|
|
|
7
10
|
class PayWall extends React.Component {
|
|
8
11
|
constructor(props) {
|
|
9
12
|
super(props);
|
|
10
13
|
this.webviewRef = React.createRef();
|
|
14
|
+
this.paywallData = {};
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
getURL = () => {
|
|
14
|
-
return "https://
|
|
18
|
+
return "https://apaq09.gways.org/card/ZLp_slash_QSy94h9aKdNJWvvvkE8dkHSyeiTGRxsZVQAaiiYveh2jTjeZVJnnIZ0WVKTgiRoAkEoVrB2leXjt_slash_l2g2MtLKRa_slash_30mL6tMu0L9IJxY=?dsn_id=6274";
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
getPayWallJS = () => {
|
|
18
|
-
return "";
|
|
22
|
+
// return "window.subInfoInterval = setInterval(() => window.Appquiles && Appquiles.setSubscriptionPlans(" + JSON.stringify(information.subsPlansInfo) + "), 300);" : '';
|
|
23
|
+
return "window.subInfoInterval = setInterval(() => window.Appquiles, 300);";
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getPayWallData = (type, keyword) => {
|
|
28
|
+
if (!config.PAYWALL_DATA[type] || !config.PAYWALL_DATA[type][keyword]) {
|
|
29
|
+
console.log('No se encontraron datos para el paywall.');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
console.log('PayWallData: ', JSON.stringify(config.PAYWALL_DATA[type][keyword]));
|
|
33
|
+
this.paywallData = config.PAYWALL_DATA[type][keyword];
|
|
19
34
|
}
|
|
20
35
|
|
|
21
36
|
handleMessage = (message) => {
|
|
@@ -34,12 +49,40 @@ class PayWall extends React.Component {
|
|
|
34
49
|
}
|
|
35
50
|
}
|
|
36
51
|
|
|
52
|
+
// --------------------------------------- Eventos ---------------------------------------
|
|
53
|
+
eventClickClose = (data) => {
|
|
54
|
+
Networking.sendEvent('action', 'continue_free');
|
|
55
|
+
this.props.onClose();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
eventClickSubscribe = (data) => {
|
|
59
|
+
Networking.sendEvent('action', 'cta');
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
this.hideSpinner();
|
|
62
|
+
}, 3000);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
hideSpinner = () => {
|
|
66
|
+
const event = {
|
|
67
|
+
event: 'hideLoader',
|
|
68
|
+
value: {
|
|
69
|
+
status: true,
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
console.log('SDK setHideLoaderAppquiles',event);
|
|
73
|
+
this.webviewRef.current.injectJavaScript(
|
|
74
|
+
`Appquiles.emitAppEvent(${JSON.stringify(event)});$('.spinner').hide();`
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
// --------------------------------------- Eventos ---------------------------------------
|
|
78
|
+
|
|
37
79
|
render() {
|
|
38
|
-
const { visible, onClose } = this.props;
|
|
80
|
+
const { visible, onClose, type, keyword } = this.props;
|
|
81
|
+
this.getPayWallData(type, keyword);
|
|
39
82
|
return (
|
|
40
83
|
<BottomSheet visible={visible} onBackButtonPress={onClose} onBackdropPress={onClose}>
|
|
41
84
|
<View style={styles.bottomNavigationView}>
|
|
42
|
-
<WebView style={{flex:1}} source={{ uri: this.
|
|
85
|
+
<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()}/>
|
|
43
86
|
</View>
|
|
44
87
|
</BottomSheet>
|
|
45
88
|
);
|
package/src/libraries/Storage.js
CHANGED
|
@@ -117,8 +117,8 @@ class Storage {
|
|
|
117
117
|
try {
|
|
118
118
|
const info = await FileSystem.getInfoAsync(CREATIONS_DIR);
|
|
119
119
|
if (!info.exists) {
|
|
120
|
-
|
|
121
|
-
return;
|
|
120
|
+
await this.createCreationsDir(CREATIONS_DIR);
|
|
121
|
+
return {};
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
const directories = await FileSystem.readDirectoryAsync(CREATIONS_DIR);
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare module 'apps-sdk' {
|
|
2
|
-
import
|
|
2
|
+
import { ComponentType } from 'react';
|
|
3
3
|
|
|
4
4
|
export interface SessionData {
|
|
5
5
|
app: {
|
|
@@ -88,10 +88,11 @@ declare module 'apps-sdk' {
|
|
|
88
88
|
export interface PayWallProps {
|
|
89
89
|
visible: boolean;
|
|
90
90
|
onClose: () => void;
|
|
91
|
+
type: string;
|
|
92
|
+
keyword: string;
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
export class PayWall extends
|
|
94
|
-
}
|
|
95
|
+
export class PayWall extends Component<PayWallProps, {}> {}
|
|
95
96
|
|
|
96
97
|
export class AppsSDK {
|
|
97
98
|
initializePushNotifications(): Promise<string>;
|