diff --git a/example/android/reactnativenotification/proguard-rules.pro b/example/android/reactnativenotification/proguard-rules.pro index d6036156526227c05fb4de73698aa38e45e7602e..57dcf0f7c50e676d70b08177e13e257a85a20017 100644 --- a/example/android/reactnativenotification/proguard-rules.pro +++ b/example/android/reactnativenotification/proguard-rules.pro @@ -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 { *; } diff --git a/example/index.android.js b/example/index.android.js index dd4f177329f5a06729fb852178ebe250695fc0b1..c63a5d3386cf45de1ac8fe3ef28d480a90ea4af9 100644 --- a/example/index.android.js +++ b/example/index.android.js @@ -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 ( - {console.log("Touch")}}> - Wix React Native Notifications - - Last notification: - {this.state.lastNotification ? this.state.lastNotification.body + ` (opened at ''${this.state.notificationRxTime})` : "N/A"} - Time elapsed: {this.state.elapsed} + Wix React Native Notifications + {this.state.initialNotification ? 'Opened from notification' : ''} + Last notification: {this.state.lastNotification ? '\n'+this.state.lastNotification.body + ` (opened at ''${this.state.notificationRxTime})` : "N/A"} + Time elapsed: {this.state.elapsed} ) } diff --git a/example/notifications.android.js b/example/notifications.android.js index 374df899d7eb3218212759823b99d2efa0550b80..1fc102632e97e1a3baf9ab8cf09fde09f821d467 100644 --- a/example/notifications.android.js +++ b/example/notifications.android.js @@ -1,7 +1,7 @@ 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()); }