Commit 7cbf9f65 authored by Amit Davidi's avatar Amit Davidi

Issue #21: Change getInitialNotification() to work like iOS when no notif is available

parent 6cb7dd19
...@@ -105,8 +105,9 @@ import com.wix.reactnativenotifications.RNNotificationsPackage; ...@@ -105,8 +105,9 @@ import com.wix.reactnativenotifications.RNNotificationsPackage;
protected List<ReactPackage> getPackages() { protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList( return Arrays.<ReactPackage>asList(
new MainReactPackage(), new MainReactPackage(),
... // ...
new RNNotificationsPackage(MainApplication.this), new RNNotificationsPackage(MainApplication.this)
);
``` ```
### Receiving push notifications ### Receiving push notifications
......
...@@ -89,7 +89,7 @@ class MainComponent extends Component { ...@@ -89,7 +89,7 @@ class MainComponent extends Component {
componentDidMount() { componentDidMount() {
console.log('ReactScreen', 'componentDidMount'); console.log('ReactScreen', 'componentDidMount');
PendingNotifications.getInitialNotification() 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)); .catch((err) => console.error("getInitialNotifiation failed", err));
} }
......
...@@ -60,7 +60,7 @@ export class PendingNotifications { ...@@ -60,7 +60,7 @@ export class PendingNotifications {
static getInitialNotification() { static getInitialNotification() {
return RNNotifications.getInitialNotification() return RNNotifications.getInitialNotification()
.then((rawNotification) => { .then((rawNotification) => {
return new NotificationAndroid(rawNotification); return rawNotification ? new NotificationAndroid(rawNotification) : undefined;
}); });
} }
} }
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