apps-sdk 1.0.31 → 1.0.33

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