apps-sdk 1.0.26 → 1.0.28

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} from "./src/libraries";
1
+ import {NotificationsPush, Networking, Storage, Session, Utils, PayWall} from "./src/libraries";
2
2
 
3
3
  class AppsSDK {
4
4
  initializePushNotifications = async() => {
@@ -17,5 +17,6 @@ export default {
17
17
  networking: Networking,
18
18
  storage: Storage,
19
19
  session: Session,
20
- utils: Utils
20
+ utils: Utils,
21
+ paywall: PayWall
21
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -18,7 +18,8 @@
18
18
  "expo-media-library": "^15.9.1",
19
19
  "expo-notifications": "^0.23.0",
20
20
  "expo-sharing": "^11.10.0",
21
- "react-native": "^0.73.2"
21
+ "react-native": "^0.73.2",
22
+ "react-native-webview": "^13.8.1"
22
23
  },
23
24
  "types": "./types/index.d.ts"
24
25
  }
@@ -0,0 +1,36 @@
1
+ import React from "react";
2
+ import { WebView } from 'react-native-webview';
3
+ import Utils from "./utils";
4
+
5
+ class PayWall {
6
+ webviewRef = React.createRef();
7
+
8
+ handleMessage = (message) => {
9
+ const data = JSON.parse(message.nativeEvent.data);
10
+ const event = "event" + Utils.capitalize(data.query);
11
+ if (typeof this[event] === 'function') {
12
+ this[event](data);
13
+ } else {
14
+ console.log(`El método ${event} no existe en la clase.`);
15
+ }
16
+ }
17
+
18
+ getPayWallJS = () => {
19
+ return "window.subInfoInterval = setInterval(() => window.Appquiles && Appquiles.setSubscriptionPlans(" + JSON.stringify(information.subsPlansInfo) + "), 300);";
20
+ }
21
+
22
+ async showPayWall(url) {
23
+ return (
24
+ <WebView style={styles.webview} source={{ uri: url }} javaScriptEnabled ref={webviewRef} onMessage={handleMessage} onError={(err) => {console.log('Error al cargar webview:',err)}} injectedJavaScript={getPayWallJS()} >
25
+ </WebView>
26
+ );
27
+ }
28
+ }
29
+
30
+ const styles = StyleSheet.create({
31
+ webview: {
32
+ flex: 1,
33
+ }
34
+ });
35
+
36
+ export default new PayWall();
@@ -187,14 +187,12 @@ class Storage {
187
187
  }
188
188
  }
189
189
 
190
- async handleShareFile(url, fileName) {
191
- const fileUri = FileSystem.documentDirectory + fileName;
192
- const { uri: localUri } = await FileSystem.downloadAsync(url, fileUri);
190
+ async handleShareFile(fileName) {
193
191
  if (!(await Sharing.isAvailableAsync())) {
194
192
  alert('Compartir no está disponible en tu plataforma.');
195
- return;
193
+ return false;
196
194
  }
197
- await Sharing.shareAsync(localUri);
195
+ return await Sharing.shareAsync(fileName);
198
196
  }
199
197
  }
200
198
 
@@ -12,6 +12,14 @@ class Utils {
12
12
  if (str ==='' || str.trim() ===''){ return false; }
13
13
  return str.startsWith('data:image/');
14
14
  }
15
+
16
+ capitalize = (text) => {
17
+ let result = '';
18
+ if (typeof text === 'string') {
19
+ result = text.charAt(0).toUpperCase() + text.slice(1);
20
+ }
21
+ return result;
22
+ };
15
23
  }
16
24
 
17
25
  export default new Utils();
@@ -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 PayWall } from './PayWall';
6
7
 
package/types/index.d.ts CHANGED
@@ -56,7 +56,7 @@ declare module 'apps-sdk' {
56
56
  getEndpoints(): any;
57
57
  setEvents(events: any): void;
58
58
  sendEvent(eventType: string, eventKeyword:string, eventData?: object): Promise<void>;
59
- }
59
+ }
60
60
 
61
61
  export class Storage {
62
62
  storeData(key: string, value: any): Promise<void>;
@@ -64,9 +64,9 @@ declare module 'apps-sdk' {
64
64
  printAllKeys(): Promise<void>;
65
65
  removeData(key: string): Promise<void>;
66
66
  handleDownloadImage(url: string, filename: string): Promise<void>;
67
- handleShareFile(url: string, filename: string): Promise<void>;
67
+ handleShareFile(filename: string): Promise<boolean>;
68
68
  createCreationsDir(dirName: string): Promise<void>;
69
- handleDownloadImageToCreations(base64Image: string, fileName: string, data: object): Promise<void>;
69
+ handleDownloadImageToCreations(base64Image: string, fileName: string, data: object): Promise<{ directoryUri: string, fileUri: string, fileData: any }>;
70
70
  getCreations(): Promise<any>;
71
71
  deleteCreation(dirName: string): Promise<void>;
72
72
  deleteAllCreations(): Promise<void>;
@@ -83,6 +83,10 @@ declare module 'apps-sdk' {
83
83
  registerForPushNotificationsAsync(): Promise<string>;
84
84
  }
85
85
 
86
+ export class PayWall {
87
+ showPayWall(url: string): Promise<void>;
88
+ }
89
+
86
90
  export class AppsSDK {
87
91
  initializePushNotifications(): Promise<string>;
88
92
  }
@@ -92,6 +96,8 @@ declare module 'apps-sdk' {
92
96
  networking: Networking;
93
97
  storage: Storage;
94
98
  session: Session;
99
+ utils: Utils;
100
+ payWall: PayWall;
95
101
  }
96
102
 
97
103
  const Core: AppsSDK;