Skip to content
Browse files

PushNotificationIOS: Use PushNotificationEventName as the key to stor…

…e in the handler map

If we are using the same handler for different events, e.g. both `notification` and `localNotification` use `_onNotification()` handler, the former listener stored in `_notifHandlers` would be overridden by the latter so it's impossible to remove the `notification` listener when we call `removeEventListener`.

This PR stores the listeners by using `pushNotificationEventName` (notification, localNotification, register or registrationError) as the key.

Use the same handler for `notification` and `localNotification`, both listeners will be removed when calling `removeEventListener`.
Closes #10776

Differential Revision: D4168722

Pulled By: hramos

fbshipit-source-id: d68581428d2acde314f7b5333feafe1ec7807159
  • Loading branch information
ianlin authored and Facebook Github Bot committed Nov 14, 2016
1 parent 015a497 commit e51cb349cef321872d963ce685943576c55cf1d3
Showing with 3 additions and 3 deletions.
  1. +3 −3 Libraries/PushNotificationIOS/PushNotificationIOS.js
@@ -258,7 +258,7 @@ class PushNotificationIOS {
_notifHandlers.set(handler, listener);
_notifHandlers.set(type, listener);

@@ -270,12 +270,12 @@ class PushNotificationIOS {
type === 'notification' || type === 'register' || type === 'registrationError' || type === 'localNotification',
'PushNotificationIOS only supports `notification`, `register`, `registrationError`, and `localNotification` events'
var listener = _notifHandlers.get(handler);
var listener = _notifHandlers.get(type);
if (!listener) {


0 comments on commit e51cb34

Please sign in to comment.