[MM-19927] Fix launching app from push notification on iOS (#3527)

* Call getInitialNotification on configure

* Mock getInitialNotification
This commit is contained in:
Miguel Alatzar 2019-11-07 12:47:52 -07:00 committed by CJ
parent f2c47def31
commit 5360989336
2 changed files with 17 additions and 0 deletions

View file

@ -66,6 +66,22 @@ class PushNotification {
this.onReply = options.onReply;
this.requestNotificationReplyPermissions();
if (options.popInitialNotification) {
NotificationsIOS.getInitialNotification().
then((notification) => {
if (notification) {
const data = notification.getData();
if (data) {
ephemeralStore.appStartedFromPushNotification = true;
this.handleNotification(data, false, true);
}
}
}).
catch((err) => {
console.log('iOS getInitialNotifiation() failed', err); //eslint-disable-line no-console
});
}
}
requestNotificationReplyPermissions = () => {

View file

@ -33,6 +33,7 @@ jest.mock('react-native-notifications', () => {
NotificationAction: jest.fn(),
NotificationCategory: jest.fn(),
localNotification: jest.fn(),
getInitialNotification: jest.fn(() => Promise.resolve()),
};
});