apps-sdk 1.0.27 → 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 +3 -2
- package/package.json +3 -2
- package/src/libraries/PayWall.js +36 -0
- package/src/libraries/Utils.js +8 -0
- package/src/libraries/index.js +1 -0
- package/types/index.d.ts +6 -0
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.
|
|
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();
|
package/src/libraries/Utils.js
CHANGED
|
@@ -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();
|
package/src/libraries/index.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -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;
|