- I am curently trying to implement a test for push notifications but I am facing some troubles with the handling system.
My e2e test looks like this:
```
it('Init from push notification', async () => {
await device.launchApp({newInstance: true, userNotification: userNotificationPushTrigger});
await expect(element(by.text('From push'))).toBeVisible();
});
const userNotificationPushTrigger = {
"trigger": {
"type": "push"
},
"title": "From push",
"subtitle": "Subtitle",
"body": "Body",
"badge": 1,
"payload": {
"key1": "value1",
"key2": "value2"
},
"category": "com.example.category",
"content-available": 0,
"action-identifier": "default"
};
```
As I saw in docs, the handling system should look like this:
_onNotification(notification) { console.log('App@onNotification:', notification); this.setState({notification: notification.getAlert()}); }
Can someone explain to me how this _onNotification() function work? More exactly how that notification object is parsed from e2e test to app.js screen.
Also the path for the _onNotification is Detox/detox/test/src/app.js.
I found the example for handling in the link below: https://github.com/wix/Detox/blob/47a921076194ac3a9ca6c875afe1b2ce4b7f91c6/detox/test/src/app.js#L153
And the test example https://github.com/wix/Detox/blob/master/detox/test/e2e/11.user-notifications.test.js