apps-sdk 1.0.33 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,7 +20,6 @@
20
20
  "expo-sharing": "^11.10.0",
21
21
  "react-native": "^0.73.2",
22
22
  "react-native-btr": "^2.2.1",
23
- "react-native-safe-area-context": "^4.9.0",
24
23
  "react-native-webview": "^13.8.1"
25
24
  },
26
25
  "types": "./types/index.d.ts"
@@ -1,22 +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
4
  import { View } from "react-native";
5
- import { SafeAreaView } from 'react-native-safe-area-context';
6
5
  import Utils from "./Utils";
7
6
 
8
- export default function PayWall({ visible, onClose }) {
9
- const webviewRef = useRef(null);
7
+ class PayWall extends React.Component {
8
+ constructor(props) {
9
+ super(props);
10
+ this.webviewRef = React.createRef();
11
+ }
10
12
 
11
- const getURL = () => {
13
+ getURL = () => {
12
14
  return "https://www.google.com";
13
15
  }
14
16
 
15
- const getPayWallJS = () => {
17
+ getPayWallJS = () => {
16
18
  return "";
17
19
  }
18
20
 
19
- const handleMessage = (message) => {
21
+ handleMessage = (message) => {
20
22
  const data = JSON.parse(message.nativeEvent.data);
21
23
  const event = "event" + Utils.capitalize(data.query);
22
24
  if (typeof this[event] === 'function') {
@@ -26,41 +28,30 @@ export default function PayWall({ visible, onClose }) {
26
28
  }
27
29
  }
28
30
 
29
- useEffect(() => {
30
- if (visible) {
31
- webviewRef.current.injectJavaScript(getPayWallJS());
31
+ componentDidUpdate(prevProps) {
32
+ if (this.props.visible && !prevProps.visible) {
33
+ this.webviewRef.current.injectJavaScript(this.getPayWallJS());
32
34
  }
33
- }, [visible]);
35
+ }
34
36
 
35
- return (
36
- <SafeAreaView>
37
- <BottomSheet
38
- visible={visible}
39
- onBackButtonPress={onClose}
40
- onBackdropPress={onClose}
41
- >
37
+ render() {
38
+ const { visible, onClose } = this.props;
39
+ return (
40
+ <BottomSheet visible={visible} onBackButtonPress={onClose} onBackdropPress={onClose}>
42
41
  <View style={styles.bottomNavigationView}>
43
- <WebView
44
- style={{flex:1}}
45
- source={{ uri: getURL() }}
46
- javaScriptEnabled
47
- ref={webviewRef}
48
- onMessage={handleMessage}
49
- onError={(err) => {console.log('Error al cargar webview:',err)}}
50
- injectedJavaScript={getPayWallJS()}
51
- />
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()}/>
52
43
  </View>
53
44
  </BottomSheet>
54
- </SafeAreaView>
55
- );
45
+ );
46
+ }
56
47
  }
57
48
 
58
49
  const styles = {
59
50
  bottomNavigationView: {
60
51
  backgroundColor: '#fff',
61
52
  width: '100%',
62
- height: '100%',
53
+ height: '95%',
63
54
  },
64
55
  }
65
56
 
66
-
57
+ export default PayWall;
package/types/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  declare module 'apps-sdk' {
2
- import { ComponentType } from 'react';
3
- import { BottomSheetProps } from 'react-native-btr';
2
+ import React, { ComponentType } from 'react';
4
3
 
5
4
  export interface SessionData {
6
5
  app: {
@@ -86,11 +85,14 @@ declare module 'apps-sdk' {
86
85
  registerForPushNotificationsAsync(): Promise<string>;
87
86
  }
88
87
 
89
- export class PayWall {
88
+ export interface PayWallProps {
90
89
  visible: boolean;
91
90
  onClose: () => void;
92
91
  }
93
92
 
93
+ export class PayWall extends React.Component<PayWallProps, {}> {
94
+ }
95
+
94
96
  export class AppsSDK {
95
97
  initializePushNotifications(): Promise<string>;
96
98
  }