@braze/web-sdk
Version:
Braze SDK for web sites and other JS platforms.
47 lines (46 loc) • 1.79 kB
JavaScript
const vt = {
qn: () =>
"serviceWorker" in navigator &&
"undefined" != typeof ServiceWorkerRegistration &&
"showNotification" in ServiceWorkerRegistration.prototype &&
"PushManager" in window,
En: () =>
"safari" in window &&
"pushNotification" in window.safari &&
"function" == typeof window.safari.pushNotification.permission &&
"function" == typeof window.safari.pushNotification.requestPermission,
isPushSupported: () => vt.qn() || vt.En(),
isPushBlocked: () => {
const o =
vt.isPushSupported() &&
"Notification" in window &&
null != window.Notification &&
null != window.Notification.permission &&
"denied" === window.Notification.permission,
i =
vt.isPushSupported() &&
(!("Notification" in window) || null == window.Notification);
return o || i;
},
isPushPermissionGranted: () =>
vt.isPushSupported() &&
"Notification" in window &&
null != window.Notification &&
null != window.Notification.permission &&
"granted" === window.Notification.permission,
en: () =>
vt.isPushBlocked()
? { sn: !1, reason: "blocked" }
: vt.isPushSupported()
? vt.isPushPermissionGranted()
? { sn: !1, reason: "permissionGranted" }
: { sn: !0 }
: { sn: !1, reason: "unsupported" },
on: (o, i) =>
"blocked" === o
? `${i} containing a push prompt is not being shown because the user has already declined push permission prompt.`
: "unsupported" === o
? `${i} containing a push prompt is not being shown because the browser doesn't support push notifications.`
: `${i} containing a push prompt is not being shown because the user has already accepted the permission prompt.`,
};
export default vt;