Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
new Promise(resolve =>
PushNotifications.popInitialNotification(n => {
const notification = Constants.normalizePush(n)
if (notification) {
resolve(PushGen.createNotification({notification}))
}
resolve(null)
})
)
sendDeviceTokenToServer(deviceToken) {
PushNotification.popInitialNotification((notification) => {
if (notification) { this.handleNotification(notification); }
});
fetch(config.serverURL + '/api/user/device', {
method: 'post',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'x-access-token': this.props.user.accessToken,
},
body: JSON.stringify({
deviceToken,
}),
})
.then(response => response.json())
.then(json => {
if (json.success === false) {
new Promise(resolve => {
PushNotifications.popInitialNotification(n => {
const notification = Constants.normalizePush(n)
if (!notification) {
resolve(null)
return
}
if (notification.type === 'follow') {
if (notification.username) {
resolve({startupFollowUser: notification.username})
return
}
} else if (notification.type === 'chat.newmessage') {
if (notification.conversationIDKey) {
resolve({startupConversation: notification.conversationIDKey})
return
}
}