Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import PushNotification from 'react-native-push-notification';
PushNotification.configure({
onNotification: (notification) => {
notification.finish("UIBackgroundFetchResultNoData");
},
onRegister: (token) => {},
senderID: 'XXX',
popInitialNotification: false,
requestPermissions: true,
});
PushNotification.unregister();
PushNotification.localNotification = (details) => {};
PushNotification.localNotificationSchedule = (details) => {};
PushNotification.requestPermissions();
PushNotification.presentLocalNotification = (details) => {};
PushNotification.scheduleLocalNotification = (details) => {};
PushNotification.cancelLocalNotifications = (details) => {};
PushNotification.cancelAllLocalNotifications();
PushNotification.setApplicationIconBadgeNumber(1);
PushNotification.getApplicationIconBadgeNumber((badgeCount) => {});
PushNotification.popInitialNotification((notification) => {});
PushNotification.checkPermissions((checkPermissions) => {});
PushNotification.abandonPermissions();
PushNotification.registerNotificationActions(['Accept', 'Reject', 'Yes', 'No']);
PushNotification.clearAllNotifications();
onPress={async () => {
let permissions
try {
permissions = await PushNotification.requestPermissions()
} catch (error) {
Sentry.captureMessage(error.toString())
props.onRequestClose()
}
await props.setNotificationsRequested(true)
if (permissions && permissions.alert) {
props.onRequestClose()
}
}}
/>
function requestPushPermissions(): Promise<*> {
return isIOS ? PushNotifications.requestPermissions() : Promise.resolve()
}
request() {
if (this.requesting === false) {
LOGi.notifications("NotificationHandler: Requesting push permissions");
this.requesting = true;
PushNotification.requestPermissions();
}
else {
LOGi.notifications("NotificationHandler: Push permissions request already pending.");
}
}
}
function requestPushPermissions() {
return isIOS ? PushNotifications.requestPermissions() : Promise.resolve()
}
onPress: () => PushNotification.requestPermissions()
}
return new Promise((resolve, reject) => {
try {
RNPushNotification.requestPermissions()
resolve()
} catch (error) {
reject(error)
}
})
}
componentDidUpdate(prevProps) {
if (!prevProps.enabled && this.props.enabled) {
PushNotification.requestPermissions();
}
if (this.props.badge !== prevProps.badge) {
this.updateAppBadge();
}
if (this.props.tab === "info" && prevProps.tab !== "info") {
this.eventuallyMarkNotificationsAsSeen();
}
}
PushNotification.checkPermissions(({ alert, badge, sound }) => {
if (!alert || !badge || !sound) {
PushNotification.requestPermissions()
.then((target) => {
if (target.alert || target.badge || target.sound) {
resolve();
} else {
reject();
}
});
} else {
resolve();
}
});
} else {