apps-sdk 1.0.33 → 1.0.35

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
@@ -1,10 +1,10 @@
1
1
  export var ENDPOINTS = {
2
- INIT : 'https://ap0404.gways.org/v6/init',
3
- NOTIFICATION_TOKEN: 'https://ap0404.gways.org/user/set_expo_id',
4
- TRACKING: 'https://ap0404.gways.org/v3/log-event',
5
- GET_USER_ID: 'https://ap0404.gways.org/user/generate_public_id',
6
- CHECK_SUBSCRIPTION: 'https://ap0404.gways.org/create-sub',
7
- SET_ATTRIBUTION: 'https://ap0404.gways.org/user/set_attribution_data',
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 = {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,7 +20,6 @@
20
20
  "expo-sharing": "^11.10.0",
21
21
  "react-native": "^0.73.2",
22
22
  "react-native-btr": "^2.2.1",
23
- "react-native-safe-area-context": "^4.9.0",
24
23
  "react-native-webview": "^13.8.1"
25
24
  },
26
25
  "types": "./types/index.d.ts"
@@ -44,7 +44,7 @@ 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
50
  }
@@ -1,22 +1,37 @@
1
- import React, { useRef, useEffect } from 'react';
1
+ import React from 'react';
2
2
  import { BottomSheet } from 'react-native-btr';
3
3
  import { WebView } from 'react-native-webview';
4
4
  import { View } from "react-native";
5
- import { SafeAreaView } from 'react-native-safe-area-context';
6
5
  import Utils from "./Utils";
6
+ import Networking from "./Networking";
7
+ import Session from "./Session";
8
+ import * as config from "../../config";
7
9
 
8
- export default function PayWall({ visible, onClose }) {
9
- const webviewRef = useRef(null);
10
+ class PayWall extends React.Component {
11
+ constructor(props) {
12
+ super(props);
13
+ this.webviewRef = React.createRef();
14
+ this.paywallData = {};
15
+ }
10
16
 
11
- const getURL = () => {
12
- return "https://www.google.com";
17
+ getURL = () => {
18
+ return "https://apaq09.gways.org/card/ZLp_slash_QSy94h9aKdNJWvvvkE8dkHSyeiTGRxsZVQAaiiYveh2jTjeZVJnnIZ0WVKTgiRoAkEoVrB2leXjt_slash_l2g2MtLKRa_slash_30mL6tMu0L9IJxY=?dsn_id=6274";
13
19
  }
14
20
 
15
- const getPayWallJS = () => {
21
+ getPayWallJS = () => {
16
22
  return "";
17
23
  }
18
24
 
19
- const handleMessage = (message) => {
25
+ getPayWallData = (type, keyword) => {
26
+ if (!config.PAYWALL_DATA[type] || !config.PAYWALL_DATA[type][keyword]) {
27
+ console.log('No se encontraron datos para el paywall.');
28
+ return;
29
+ }
30
+ console.log('PayWallData: ', JSON.stringify(config.PAYWALL_DATA[type][keyword]));
31
+ this.paywallData = config.PAYWALL_DATA[type][keyword];
32
+ }
33
+
34
+ handleMessage = (message) => {
20
35
  const data = JSON.parse(message.nativeEvent.data);
21
36
  const event = "event" + Utils.capitalize(data.query);
22
37
  if (typeof this[event] === 'function') {
@@ -26,41 +41,57 @@ export default function PayWall({ visible, onClose }) {
26
41
  }
27
42
  }
28
43
 
29
- useEffect(() => {
30
- if (visible) {
31
- webviewRef.current.injectJavaScript(getPayWallJS());
44
+ componentDidUpdate(prevProps) {
45
+ if (this.props.visible && !prevProps.visible) {
46
+ this.webviewRef.current.injectJavaScript(this.getPayWallJS());
47
+ }
48
+ }
49
+
50
+ // --------------------------------------- Eventos ---------------------------------------
51
+ eventClickClose = (data) => {
52
+ Networking.sendEvent('action', 'continue_free');
53
+ this.props.onClose();
54
+ }
55
+
56
+ eventClickSubscribe = (data) => {
57
+ Networking.sendEvent('action', 'cta');
58
+ setTimeout(() => {
59
+ hideSpinner();
60
+ }, 3000);
61
+ }
62
+
63
+ hideSpinner = () => {
64
+ const event = {
65
+ event: 'hideLoader',
66
+ value: {
67
+ status: true,
68
+ }
32
69
  }
33
- }, [visible]);
70
+ this.webviewRef.injectJavaScript(
71
+ `Appquiles.emitAppEvent(${JSON.stringify(event)});`,
72
+ )
73
+ }
74
+ // --------------------------------------- Eventos ---------------------------------------
34
75
 
35
- return (
36
- <SafeAreaView>
37
- <BottomSheet
38
- visible={visible}
39
- onBackButtonPress={onClose}
40
- onBackdropPress={onClose}
41
- >
76
+ render() {
77
+ const { visible, onClose, type, keyword } = this.props;
78
+ this.getPayWallData(type, keyword);
79
+ return (
80
+ <BottomSheet visible={visible} onBackButtonPress={onClose} onBackdropPress={onClose}>
42
81
  <View style={styles.bottomNavigationView}>
43
- <WebView
44
- style={{flex:1}}
45
- source={{ uri: getURL() }}
46
- javaScriptEnabled
47
- ref={webviewRef}
48
- onMessage={handleMessage}
49
- onError={(err) => {console.log('Error al cargar webview:',err)}}
50
- injectedJavaScript={getPayWallJS()}
51
- />
82
+ <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()}/>
52
83
  </View>
53
84
  </BottomSheet>
54
- </SafeAreaView>
55
- );
85
+ );
86
+ }
56
87
  }
57
88
 
58
89
  const styles = {
59
90
  bottomNavigationView: {
60
91
  backgroundColor: '#fff',
61
92
  width: '100%',
62
- height: '100%',
93
+ height: '95%',
63
94
  },
64
95
  }
65
96
 
66
-
97
+ export default PayWall;
@@ -117,8 +117,8 @@ class Storage {
117
117
  try {
118
118
  const info = await FileSystem.getInfoAsync(CREATIONS_DIR);
119
119
  if (!info.exists) {
120
- console.error('El directorio no existe:', CREATIONS_DIR);
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,6 +1,5 @@
1
1
  declare module 'apps-sdk' {
2
- import { ComponentType } from 'react';
3
- import { BottomSheetProps } from 'react-native-btr';
2
+ import React, { ComponentType } from 'react';
4
3
 
5
4
  export interface SessionData {
6
5
  app: {
@@ -86,9 +85,14 @@ declare module 'apps-sdk' {
86
85
  registerForPushNotificationsAsync(): Promise<string>;
87
86
  }
88
87
 
89
- export class PayWall {
88
+ export interface PayWallProps {
90
89
  visible: boolean;
91
90
  onClose: () => void;
91
+ type: string;
92
+ keyword: string;
93
+ }
94
+
95
+ export class PayWall extends React.Component<PayWallProps, {}> {
92
96
  }
93
97
 
94
98
  export class AppsSDK {