Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount() {
OneSignal.addEventListener('ids', this.onIds);
OneSignal.addEventListener('opened', this._onOpened.bind(this));
OneSignal.inFocusDisplaying(global.inAppNotification);
AppState.addEventListener('change', this._handleAppStateChange);
// Android only: clear notifications (badge count) when user is in app
if (Platform.OS !== 'ios') {
OneSignal.clearOneSignalNotifications();
}
AsyncStorage.getItem('@Discourse.skipLogin').then(json => {
if (json && json === 'loginSkipped') {
this.setState({skipLogin: true});
}
});
this.keyboardDidShowListener = Keyboard.addListener(
'keyboardDidShow',
this._keyboardDidShow.bind(this),
);
this.keyboardDidHideListener = Keyboard.addListener(
'keyboardDidHide',
this._keyboardDidHide.bind(this),
);
componentDidAppear() {
// Everytime user shows notifications tab, clear them
OneSignal.clearOneSignalNotifications();
}
it("must call it without errors", () => {
OneSignal.clearOneSignalNotifications();
});
});
it('must call it without errors', () => {
OneSignal.clearOneSignalNotifications();
});
});
_handleAppStateChange = nextAppState => {
console.log('APPSTATE: ' + nextAppState);
if (
this.state.appState.match(/inactive|background/) &&
nextAppState === 'active'
) {
if (Platform.OS !== 'ios') {
OneSignal.clearOneSignalNotifications();
}
}
this.setState({appState: nextAppState});
};
onMarkAll = async () => {
OneSignal.clearOneSignalNotifications();
await this.props.markAllNotificationsAsRead();
this.updateNotificationCount();
};