Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (PushService._token.os === 'android') {
data.token = {
gcm: PushService._token.token,
};
} else if (PushService._token.os === 'ios') {
data.token = {
apn: PushService._token.token,
};
}
// console.log('==============> push =================', data);
Meteor.call('raix:push-update', data, (err, res) => {
AppUtil.debug('Push backend', JSON.stringify(res));
});
// clear badges on init
PushNotification.setApplicationIconBadgeNumber(0);
}
}
const updateAppBadge = (_, action) => {
const count = (action.payload.badgeState.conversations || []).reduce(
(total, c) => (c.badgeCounts ? total + c.badgeCounts[`${RPCTypes.commonDeviceType.mobile}`] : total),
0
)
PushNotifications.setApplicationIconBadgeNumber(count)
// Only do this native call if the count actually changed, not over and over if its zero
if (count === 0 && lastCount !== 0) {
PushNotifications.cancelAllLocalNotifications()
}
lastCount = count
}
ongoing: false,
});
}
else {
PushNotification.localNotification({
category: 'newMessage',
data: data,
userInfo: data,
title: "New Message Found\n", // (optional, for iOS this is only used in apple watch, the title will be the app name on other iOS devices)
message: messageData.content, // (required)
playSound: true, // (optional) default: true
});
}
PushNotification.setApplicationIconBadgeNumber(1);
}
else {
if (!alreadyNotified) {
Toast.showWithGravity(' Message found! ', Toast.SHORT, Toast.CENTER);
LOG.info("LocalNotifications: on the front, just vibe.");
// notify the user by vibration that the crownstone will be switched.
Vibration.vibrate(200, false);
}
}
return true;
}
}
return false;
},
_clearBadge() {
// if there is a badge number, remove it on opening the app.
PushNotification.setApplicationIconBadgeNumber(0);
}
},
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();
number =>
number > 0 && PushNotification.setApplicationIconBadgeNumber(0),
)
componentWillReceiveProps(props) {
if (this.isConfigured) {
DeviceNotification.setApplicationIconBadgeNumber(props.mentionCount);
}
}