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 CHANGED
@@ -19,5 +19,4 @@ export default {
19
19
  session: Session,
20
20
  utils: Utils,
21
21
  paywall: PayWall,
22
- paywall2: PayWall2
23
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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 class PayWall extends React.Component {
8
- webviewRef = React.createRef();
9
- bottomSheetRef = React.createRef();
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
- getPayWallJS = () => {
22
- return "window.subInfoInterval = setInterval(() => window.Appquiles && Appquiles.setSubscriptionPlans(" + JSON.stringify(information.subsPlansInfo) + "), 300);";
23
- }
25
+ useEffect(() => {
26
+ if (visible) {
27
+ webviewRef.current.injectJavaScript(getPayWallJS());
28
+ }
29
+ }, [visible]);
24
30
 
25
- render() {
26
- return (
27
- this.props.isVisible &&
28
- <View style={styles.container}>
29
- <BottomSheet
30
- ref={this.bottomSheetRef}
31
- height={0.9 * Dimensions.get('window').height} // 90% de la altura de la pantalla
32
- open={true}
33
- customStyles={{
34
- container: {
35
- flex: 1,
36
- borderTopLeftRadius: 10,
37
- borderTopRightRadius: 10,
38
- }
39
- }}
40
- >
41
- <WebView
42
- style={styles.webview}
43
- source={{ uri: this.props.url }}
44
- javaScriptEnabled
45
- ref={this.webviewRef}
46
- onMessage={this.handleMessage}
47
- onError={(err) => {console.log('Error al cargar webview:',err)}}
48
- injectedJavaScript={this.getPayWallJS()}
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
- });
@@ -4,5 +4,3 @@ export { default as Storage } from './Storage';
4
4
  export { default as Session } from './Session';
5
5
  export { default as Utils } from './Utils';
6
6
  export { default as PayWall } from './PayWall';
7
- export { default as PayWall2 } from './PayWall2';
8
-
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
- }