From 7cbf9f653edc7e10060e80d3228a89c2507449d2 Mon Sep 17 00:00:00 2001 From: Amit Davidi Date: Mon, 23 Jan 2017 13:15:07 +0200 Subject: [PATCH] Issue #21: Change getInitialNotification() to work like iOS when no notif is available --- README.md | 9 +++++---- example/index.android.js | 2 +- index.android.js | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 275b61d..42cfeec 100644 --- a/README.md +++ b/README.md @@ -103,10 +103,11 @@ import com.wix.reactnativenotifications.RNNotificationsPackage; @Override protected List getPackages() { - return Arrays.asList( - new MainReactPackage(), - ... - new RNNotificationsPackage(MainApplication.this), + return Arrays.asList( + new MainReactPackage(), + // ... + new RNNotificationsPackage(MainApplication.this) + ); ``` ### Receiving push notifications diff --git a/example/index.android.js b/example/index.android.js index 24274b1..5681d18 100644 --- a/example/index.android.js +++ b/example/index.android.js @@ -89,7 +89,7 @@ class MainComponent extends Component { componentDidMount() { console.log('ReactScreen', 'componentDidMount'); PendingNotifications.getInitialNotification() - .then((notification) => {console.log("getInitialNotification:", notification); this.setState({initialNotification: notification.getData()});}) + .then((notification) => {console.log("getInitialNotification:", notification); this.setState({initialNotification: (notification ? notification.getData() : undefined)});}) .catch((err) => console.error("getInitialNotifiation failed", err)); } diff --git a/index.android.js b/index.android.js index 4d3bca1..03fbe0d 100644 --- a/index.android.js +++ b/index.android.js @@ -60,7 +60,7 @@ export class PendingNotifications { static getInitialNotification() { return RNNotifications.getInitialNotification() .then((rawNotification) => { - return new NotificationAndroid(rawNotification); + return rawNotification ? new NotificationAndroid(rawNotification) : undefined; }); } } -- 2.26.2