apps-sdk 1.0.32 → 1.0.34

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, PayWall, PayWall2} from "./src/libraries";
1
+ import {NotificationsPush, Networking, Storage, Session, Utils, PayWall} from "./src/libraries";
2
2
 
3
3
  class AppsSDK {
4
4
  initializePushNotifications = async() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,18 +1,24 @@
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
- import {Dimensions} from "react-native";
4
+ import { View } from "react-native";
5
5
  import Utils from "./Utils";
6
6
 
7
- export default function PayWall({ visible, onClose }) {
8
- const webviewRef = useRef(null);
7
+ class PayWall extends React.Component {
8
+ constructor(props) {
9
+ super(props);
10
+ this.webviewRef = React.createRef();
11
+ }
9
12
 
13
+ getURL = () => {
14
+ return "https://www.google.com";
15
+ }
10
16
 
11
- const getPayWallJS = () => {
12
- return "window.subInfoInterval = setInterval(() => window.Appquiles && Appquiles.setSubscriptionPlans(" + JSON.stringify(information.subsPlansInfo) + "), 300);";
17
+ getPayWallJS = () => {
18
+ return "";
13
19
  }
14
20
 
15
- const handleMessage = (message) => {
21
+ handleMessage = (message) => {
16
22
  const data = JSON.parse(message.nativeEvent.data);
17
23
  const event = "event" + Utils.capitalize(data.query);
18
24
  if (typeof this[event] === 'function') {
@@ -22,35 +28,30 @@ export default function PayWall({ visible, onClose }) {
22
28
  }
23
29
  }
24
30
 
25
- useEffect(() => {
26
- if (visible) {
27
- webviewRef.current.injectJavaScript(getPayWallJS());
31
+ componentDidUpdate(prevProps) {
32
+ if (this.props.visible && !prevProps.visible) {
33
+ this.webviewRef.current.injectJavaScript(this.getPayWallJS());
28
34
  }
29
- }, [visible]);
30
-
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
- );
35
+ }
36
+
37
+ render() {
38
+ const { visible, onClose } = this.props;
39
+ return (
40
+ <BottomSheet visible={visible} onBackButtonPress={onClose} onBackdropPress={onClose}>
41
+ <View style={styles.bottomNavigationView}>
42
+ <WebView style={{flex:1}} source={{ uri: this.getURL() }} javaScriptEnabled ref={this.webviewRef} onMessage={this.handleMessage} onError={(err) => {console.log('Error al cargar webview:',err)}} injectedJavaScript={this.getPayWallJS()}/>
43
+ </View>
44
+ </BottomSheet>
45
+ );
46
+ }
47
+ }
48
+
49
+ const styles = {
50
+ bottomNavigationView: {
51
+ backgroundColor: '#fff',
52
+ width: '100%',
53
+ height: '95%',
54
+ },
56
55
  }
56
+
57
+ export default PayWall;
package/types/index.d.ts CHANGED
@@ -1,7 +1,5 @@
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';
2
+ import React, { ComponentType } from 'react';
5
3
 
6
4
  export interface SessionData {
7
5
  app: {
@@ -87,12 +85,13 @@ declare module 'apps-sdk' {
87
85
  registerForPushNotificationsAsync(): Promise<string>;
88
86
  }
89
87
 
90
- export interface PayWallProps extends BottomSheetProps {
88
+ export interface PayWallProps {
91
89
  visible: boolean;
92
90
  onClose: () => void;
93
91
  }
94
92
 
95
- export const PayWall: ComponentType<PayWallProps>;
93
+ export class PayWall extends React.Component<PayWallProps, {}> {
94
+ }
96
95
 
97
96
  export class AppsSDK {
98
97
  initializePushNotifications(): Promise<string>;
@@ -104,6 +103,7 @@ declare module 'apps-sdk' {
104
103
  storage: Storage;
105
104
  session: Session;
106
105
  utils: Utils;
106
+ paywall: PayWall;
107
107
  }
108
108
 
109
109
  const Core: AppsSDK;