I’d like to remove the remote push notification listener at some point but it seems not to work.
componentDidMount() {
registerForPushNotificationsAsync();
// Handle notifications that are received or selected while the app
// is open. If the app was closed and then opened by tapping the
// notification (rather than just tapping the app icon to open it),
// this function will fire on the next tick after the app starts
// with the notification data.
this._notificationSubscription.handler = Notifications.addListener(this._handleNotification);
console.log(this._notificationSubscription)
}
componentWillUnmount() {
this._notificationSubscription.handler.remove();
console.log(this._notificationSubscription)
}
Although console.logs seem fine and the listener seems to be removed, I’m still keeping receiving notifications on my device:
10:06:01 AM
Object {
"handler": EmitterSubscription {
"context": undefined,
"eventType": "notification",
"key": 0,
"listener": [Function anonymous],
"subscriber": EventSubscriptionVendor {
"_currentSubscription": null,
"_subscriptionsForType": Object {
"notification": Array [
[Circular],
],
},
},
},
}
10:06:02 AM
Object {
"handler": EmitterSubscription {
"context": undefined,
"eventType": "notification",
"key": 0,
"listener": [Function anonymous],
"subscriber": null,
},
}
Is there anything I am doing wrong? Or is it because I am using the Expo client (not standalone app)?