Commit 27906420 authored by Amit Davidi's avatar Amit Davidi

Fix initial notification react-method

parent d5682e8b
......@@ -15,3 +15,6 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
......@@ -16,8 +16,13 @@ const styles = StyleSheet.create({
flex: 1,
justifyContent: 'center',
},
mainText: {
fontSize: 20,
titleText: {
fontSize: 22,
textAlign: 'center',
margin: 10,
},
bodyText: {
fontSize: 18,
textAlign: 'center',
margin: 10,
},
......@@ -38,8 +43,13 @@ class MainComponent extends Component {
NotificationsAndroid.setRegistrationTokenUpdateListener(this.onPushRegistered.bind(this));
NotificationsAndroid.setNotificationOpenedListener(this.onNotificationOpened.bind(this));
NotificationsAndroid.setNotificationReceivedListener(this.onNotificationReceived.bind(this));
}
componentDidMount() {
setInterval(this.onTick.bind(this), 1000);
PendingNotifications.getInitialNotification()
.then((notification) => {console.log("getInitialNotification:", notification); this.setState({initialNotification: notification.getData()});})
.catch((err) => console.error("getInitialNotifiation failed", err));
}
onTick() {
......@@ -49,12 +59,10 @@ class MainComponent extends Component {
render() {
return (
<View style={styles.container}>
<TouchableHighlight onPress={() => {console.log("Touch")}}>
<Text style={styles.mainText}>Wix React Native Notifications</Text>
</TouchableHighlight>
<Text style={styles.mainText}>Last notification:</Text>
<Text style={styles.mainText}>{this.state.lastNotification ? this.state.lastNotification.body + ` (opened at ''${this.state.notificationRxTime})` : "N/A"}</Text>
<Text style={styles.mainText}>Time elapsed: {this.state.elapsed}</Text>
<Text style={styles.titleText}>Wix React Native Notifications</Text>
<Text style={styles.bodyText}>{this.state.initialNotification ? 'Opened from notification' : ''}</Text>
<Text style={styles.bodyText}>Last notification: {this.state.lastNotification ? '\n'+this.state.lastNotification.body + ` (opened at ''${this.state.notificationRxTime})` : "N/A"}</Text>
<Text style={styles.bodyText}>Time elapsed: {this.state.elapsed}</Text>
</View>
)
}
......
require('react');
import {NativeModules, DeviceEventEmitter} from 'react-native';
const RNNotifications = NativeModules.WixRNNotification;
const RNNotifications = NativeModules.WixRNNotifications;
let notificationReceivedListener;
let notificationOpenedListener;
......@@ -63,7 +63,7 @@ export class NotificationsAndroid {
}
}
export class PendingNotifications {
export class PendingNotifications {
static async getInitialNotification() {
return new NotificationAndroid(await RNNotifications.getInitialNotification());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment