Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
this.dispatch(updateSilentSwitchState(silent));
}
});
// Push Notifications Configure
OneSignal.addEventListener('ids', this.onIds.bind(this));
OneSignal.addEventListener('received', this.onPushNotificationReceived.bind(this));
OneSignal.configure();
// Local Notifications Configure
NotificationsIOS.addEventListener('notificationReceivedForeground', this.onNotificationReceivedForeground.bind(this));
NotificationsIOS.addEventListener('notificationReceivedBackground', this.onNotificationReceivedBackground.bind(this));
NotificationsIOS.addEventListener('notificationOpened', this.onNotificationOpened.bind(this));
this.snoozeAction = new NotificationAction({
activationMode: 'background',
title: 'Snooze',
identifier: 'SNOOZE_ACTION',
}, (action, completed) => {
this.dispatch(snoozeAlarm(action.notification.getData().alarmUUID));
completed();
});
this.stopAction = new NotificationAction({
activationMode: 'background',
title: 'Stop',
identifier: 'STOP_ACTION',
}, (action, completed) => {
this.dispatch(stopAlarm(action.notification.getData().alarmUUID));
completed();
});
// Local Notifications Configure
NotificationsIOS.addEventListener('notificationReceivedForeground', this.onNotificationReceivedForeground.bind(this));
NotificationsIOS.addEventListener('notificationReceivedBackground', this.onNotificationReceivedBackground.bind(this));
NotificationsIOS.addEventListener('notificationOpened', this.onNotificationOpened.bind(this));
this.snoozeAction = new NotificationAction({
activationMode: 'background',
title: 'Snooze',
identifier: 'SNOOZE_ACTION',
}, (action, completed) => {
this.dispatch(snoozeAlarm(action.notification.getData().alarmUUID));
completed();
});
this.stopAction = new NotificationAction({
activationMode: 'background',
title: 'Stop',
identifier: 'STOP_ACTION',
}, (action, completed) => {
this.dispatch(stopAlarm(action.notification.getData().alarmUUID));
completed();
});
this.alarmActions = new NotificationCategory({
identifier: 'ALARM',
actions: [this.snoozeAction, this.stopAction],
context: 'default',
});
this.requestPermissions().then(() => {
this.checkStatus().catch(() => {
createReplyCategory = () => {
const {getState} = this.reduxStore;
const state = getState();
const locale = getCurrentLocale(state);
const replyTitle = getLocalizedMessage(locale, t('mobile.push_notification_reply.title'));
const replyButton = getLocalizedMessage(locale, t('mobile.push_notification_reply.button'));
const replyPlaceholder = getLocalizedMessage(locale, t('mobile.push_notification_reply.placeholder'));
const replyAction = new NotificationAction({
activationMode: 'background',
title: replyTitle,
textInput: {
buttonTitle: replyButton,
placeholder: replyPlaceholder,
},
authenticationRequired: true,
identifier: REPLY_ACTION,
});
return new NotificationCategory({
identifier: CATEGORY,
actions: [replyAction],
context: 'default',
});
}
import NotificationsIOS, { NotificationAction, NotificationCategory } from 'react-native-notifications';
import reduxStore from '../../lib/createStore';
import I18n from '../../i18n';
const replyAction = new NotificationAction({
activationMode: 'background',
title: I18n.t('Reply'),
textInput: {
buttonTitle: I18n.t('Reply'),
placeholder: I18n.t('Type_message')
},
identifier: 'REPLY_ACTION'
});
class PushNotification {
constructor() {
this.onRegister = null;
this.onNotification = null;
this.deviceToken = null;
NotificationsIOS.addEventListener('remoteNotificationsRegistered', (deviceToken) => {