apps-sdk 1.0.30 → 1.0.32
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 +0 -1
- package/package.json +1 -1
- package/src/libraries/PayWall.js +41 -48
- package/src/libraries/index.js +0 -2
- package/types/index.d.ts +11 -0
- package/src/libraries/PayWall2.js +0 -15
package/index.js
CHANGED
package/package.json
CHANGED
package/src/libraries/PayWall.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { WebView } from 'react-native-webview';
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
3
2
|
import { BottomSheet } from 'react-native-btr';
|
|
3
|
+
import { WebView } from 'react-native-webview';
|
|
4
|
+
import {Dimensions} from "react-native";
|
|
4
5
|
import Utils from "./Utils";
|
|
5
|
-
import { StyleSheet, View, Dimensions } from 'react-native';
|
|
6
6
|
|
|
7
|
-
export default
|
|
8
|
-
webviewRef =
|
|
9
|
-
|
|
7
|
+
export default function PayWall({ visible, onClose }) {
|
|
8
|
+
const webviewRef = useRef(null);
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const getPayWallJS = () => {
|
|
12
|
+
return "window.subInfoInterval = setInterval(() => window.Appquiles && Appquiles.setSubscriptionPlans(" + JSON.stringify(information.subsPlansInfo) + "), 300);";
|
|
13
|
+
}
|
|
10
14
|
|
|
11
|
-
handleMessage = (message) => {
|
|
15
|
+
const handleMessage = (message) => {
|
|
12
16
|
const data = JSON.parse(message.nativeEvent.data);
|
|
13
17
|
const event = "event" + Utils.capitalize(data.query);
|
|
14
18
|
if (typeof this[event] === 'function') {
|
|
@@ -18,46 +22,35 @@ export default class PayWall extends React.Component {
|
|
|
18
22
|
}
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (visible) {
|
|
27
|
+
webviewRef.current.injectJavaScript(getPayWallJS());
|
|
28
|
+
}
|
|
29
|
+
}, [visible]);
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
</BottomSheet>
|
|
51
|
-
</View>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
31
|
+
return (
|
|
32
|
+
<BottomSheet
|
|
33
|
+
visible={visible}
|
|
34
|
+
onBackButtonPress={onClose}
|
|
35
|
+
onBackdropPress={onClose}
|
|
36
|
+
height={0.9 * Dimensions.get('window').height}
|
|
37
|
+
customStyles={{
|
|
38
|
+
container: {
|
|
39
|
+
flex: 1,
|
|
40
|
+
borderTopLeftRadius: 10,
|
|
41
|
+
borderTopRightRadius: 10,
|
|
42
|
+
}
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
<WebView
|
|
46
|
+
style={styles.webview}
|
|
47
|
+
source={{ uri: this.props.url }}
|
|
48
|
+
javaScriptEnabled
|
|
49
|
+
ref={this.webviewRef}
|
|
50
|
+
onMessage={handleMessage}
|
|
51
|
+
onError={(err) => {console.log('Error al cargar webview:',err)}}
|
|
52
|
+
injectedJavaScript={getPayWallJS()}
|
|
53
|
+
/>
|
|
54
|
+
</BottomSheet>
|
|
55
|
+
);
|
|
54
56
|
}
|
|
55
|
-
|
|
56
|
-
const styles = StyleSheet.create({
|
|
57
|
-
container: {
|
|
58
|
-
flex: 1,
|
|
59
|
-
},
|
|
60
|
-
webview: {
|
|
61
|
-
flex: 1,
|
|
62
|
-
}
|
|
63
|
-
});
|
package/src/libraries/index.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
declare module 'apps-sdk' {
|
|
2
|
+
import { ComponentType } from 'react';
|
|
3
|
+
import { WebViewProps } from 'react-native-webview';
|
|
4
|
+
import { BottomSheetProps } from 'react-native-btr';
|
|
5
|
+
|
|
2
6
|
export interface SessionData {
|
|
3
7
|
app: {
|
|
4
8
|
shortVersion: string;
|
|
@@ -83,6 +87,13 @@ declare module 'apps-sdk' {
|
|
|
83
87
|
registerForPushNotificationsAsync(): Promise<string>;
|
|
84
88
|
}
|
|
85
89
|
|
|
90
|
+
export interface PayWallProps extends BottomSheetProps {
|
|
91
|
+
visible: boolean;
|
|
92
|
+
onClose: () => void;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const PayWall: ComponentType<PayWallProps>;
|
|
96
|
+
|
|
86
97
|
export class AppsSDK {
|
|
87
98
|
initializePushNotifications(): Promise<string>;
|
|
88
99
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { BottomSheet } from 'react-native-btr';
|
|
3
|
-
import { WebView } from 'react-native-webview';
|
|
4
|
-
|
|
5
|
-
export default function PayWall2({ visible, onClose }) {
|
|
6
|
-
return (
|
|
7
|
-
<BottomSheet
|
|
8
|
-
visible={visible}
|
|
9
|
-
onBackButtonPress={onClose}
|
|
10
|
-
onBackdropPress={onClose}
|
|
11
|
-
>
|
|
12
|
-
<WebView source={{ uri: 'https://www.google.es' }} />
|
|
13
|
-
</BottomSheet>
|
|
14
|
-
);
|
|
15
|
-
}
|