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
......@@ -103,10 +103,11 @@ import com.wix.reactnativenotifications.RNNotificationsPackage;
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
...
new RNNotificationsPackage(MainApplication.this),
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
// ...
new RNNotificationsPackage(MainApplication.this)
);
```
### Receiving push notifications
......
......@@ -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));
}
......
......@@ -60,7 +60,7 @@ export class PendingNotifications {
static getInitialNotification() {
return RNNotifications.getInitialNotification()
.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