Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { link = '', notificationId = null, nativeNotificationNotShown } = payload;
/**
* The following property is only available on iOS. A value of TRUE indicates that the push
* message came in, while the app was open. Since the app would instantly open the link of the
* message in those situations, the link handling is suppressed to not distract the user.
*/
if (nativeNotificationNotShown === true) {
return;
}
if (notificationId) {
const id = notificationId.toString();
// Send tracking event to the backend
new DataRequest(PUSH_MESSAGE_OPENED)
.setPayload({ notificationId: id })
.dispatch();
}
handleLink({ link }, dispatch);
dispatch(openPushNotification(notificationId, link));
};
const handleOpenPushNotification = (payload = {}) => {
const { link = '' } = payload;
let { notificationId } = payload;
notificationId = notificationId ? notificationId.toString() : null;
if (notificationId) {
new DataRequest(PUSH_MESSAGE_OPENED)
.setPayload({
notificationId,
})
.dispatch()
.then(result => logger.info(PUSH_MESSAGE_OPENED, result))
.catch(err => err && logger.error(err));
}
if (link) {
const parsedLink = new ParsedLink(link);
parsedLink.open();
}
};
export function sendDataRequest(url) {
new DataRequest(url)
.dispatch()
.then(result => logger.info(url, result))
.catch(err => err && logger.error(err));
}
export const enableDebugLogging = () => () => {
setDebugLoggingEnabled();
(new DataRequest('ajax_started_live_logging')).dispatch();
};