Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentWillUnmount() {
switch (Platform.OS) {
case 'ios':
// prevent memory leaks!
NotificationsIOS.removeEventListener(
'remoteNotificationsRegistered',
this.onPushRegistered,
);
NotificationsIOS.removeEventListener(
'remoteNotificationsRegistrationFailed',
this.onPushRegistrationFailed,
);
NotificationsIOS.removeEventListener(
'notificationReceivedForeground',
this.onNotificationReceivedForeground,
);
NotificationsIOS.removeEventListener(
'notificationReceivedBackground',
this.onNotificationReceivedBackground,
);
NotificationsIOS.removeEventListener('notificationOpened', this.onNotificationOpened);
break;
default:
break;
}
}
componentWillUnmount() {
switch (Platform.OS) {
case 'ios':
// prevent memory leaks!
NotificationsIOS.removeEventListener(
'remoteNotificationsRegistered',
this.onPushRegistered,
);
NotificationsIOS.removeEventListener(
'remoteNotificationsRegistrationFailed',
this.onPushRegistrationFailed,
);
NotificationsIOS.removeEventListener(
'notificationReceivedForeground',
this.onNotificationReceivedForeground,
);
NotificationsIOS.removeEventListener(
'notificationReceivedBackground',
this.onNotificationReceivedBackground,
);
NotificationsIOS.removeEventListener('notificationOpened', this.onNotificationOpened);
break;
default:
break;
componentWillUnmount() {
switch (Platform.OS) {
case 'ios':
// prevent memory leaks!
NotificationsIOS.removeEventListener(
'remoteNotificationsRegistered',
this.onPushRegistered,
);
NotificationsIOS.removeEventListener(
'remoteNotificationsRegistrationFailed',
this.onPushRegistrationFailed,
);
NotificationsIOS.removeEventListener(
'notificationReceivedForeground',
this.onNotificationReceivedForeground,
);
NotificationsIOS.removeEventListener(
'notificationReceivedBackground',
this.onNotificationReceivedBackground,
);
NotificationsIOS.removeEventListener('notificationOpened', this.onNotificationOpened);
switch (Platform.OS) {
case 'ios':
// prevent memory leaks!
NotificationsIOS.removeEventListener(
'remoteNotificationsRegistered',
this.onPushRegistered,
);
NotificationsIOS.removeEventListener(
'remoteNotificationsRegistrationFailed',
this.onPushRegistrationFailed,
);
NotificationsIOS.removeEventListener(
'notificationReceivedForeground',
this.onNotificationReceivedForeground,
);
NotificationsIOS.removeEventListener(
'notificationReceivedBackground',
this.onNotificationReceivedBackground,
);
NotificationsIOS.removeEventListener('notificationOpened', this.onNotificationOpened);
break;
default:
break;
}
}
this.unsubs.push(() => NotificationsIOS.removeEventListener(name, handler));
}
async function onRegistrationError(e) {
NotificationsIOS.removeEventListener('remoteNotificationsRegistrationFailed', onRegistrationError);
log.info('PUSH: registration error', e);
reject(e);
}
NotificationsIOS.addEventListener('remoteNotificationsRegistrationFailed', onRegistrationError);
killActor() {
AppState.removeEventListener('change');
SilentSwitch.removeEventListener();
OneSignal.removeEventListener('ids', this.onIds.bind(this));
OneSignal.removeEventListener('received', this.onReceived.bind(this));
NotificationsIOS.removeEventListener('notificationReceivedForeground', this.onNotificationReceivedForeground.bind(this));
NotificationsIOS.removeEventListener('notificationReceivedBackground', this.onNotificationReceivedForeground.bind(this));
NotificationsIOS.removeEventListener('notificationOpened', this.onNotificationOpened.bind(this));
NotificationsIOS.resetCategories();
if (this.TimeWatcherActor) {
this.TimeWatcherActor.killActor(this.silent);
}
}
killActor() {
AppState.removeEventListener('change');
SilentSwitch.removeEventListener();
OneSignal.removeEventListener('ids', this.onIds.bind(this));
OneSignal.removeEventListener('received', this.onReceived.bind(this));
NotificationsIOS.removeEventListener('notificationReceivedForeground', this.onNotificationReceivedForeground.bind(this));
NotificationsIOS.removeEventListener('notificationReceivedBackground', this.onNotificationReceivedForeground.bind(this));
NotificationsIOS.removeEventListener('notificationOpened', this.onNotificationOpened.bind(this));
NotificationsIOS.resetCategories();
if (this.TimeWatcherActor) {
this.TimeWatcherActor.killActor(this.silent);
}
}
async function onRegister(deviceToken): Promise {
NotificationsIOS.removeEventListener('remoteNotificationsRegistered', onRegister);
try {
const url = `${KONNECTOR_URL}/ring/pushNotifications`;
await api.makeAuthorizedRequest(url, 'POST', {token: ytToken, appleDeviceId: deviceToken});
resolve();
} catch (err) {
reject(err);
}
}
NotificationsIOS.addEventListener('remoteNotificationsRegistered', onRegister);
killActor() {
AppState.removeEventListener('change');
SilentSwitch.removeEventListener();
OneSignal.removeEventListener('ids', this.onIds.bind(this));
OneSignal.removeEventListener('received', this.onReceived.bind(this));
NotificationsIOS.removeEventListener('notificationReceivedForeground', this.onNotificationReceivedForeground.bind(this));
NotificationsIOS.removeEventListener('notificationReceivedBackground', this.onNotificationReceivedForeground.bind(this));
NotificationsIOS.removeEventListener('notificationOpened', this.onNotificationOpened.bind(this));
NotificationsIOS.resetCategories();
if (this.TimeWatcherActor) {
this.TimeWatcherActor.killActor(this.silent);
}
}