@braze/web-sdk
Version:
Braze SDK for web sites and other JS platforms.
47 lines (46 loc) • 1.79 kB
JavaScript
const It = {
cu: () =>
"serviceWorker" in navigator &&
"undefined" != typeof ServiceWorkerRegistration &&
"showNotification" in ServiceWorkerRegistration.prototype &&
"PushManager" in window,
lu: () =>
"safari" in window &&
"pushNotification" in window.safari &&
"function" == typeof window.safari.pushNotification.permission &&
"function" == typeof window.safari.pushNotification.requestPermission,
isPushSupported: () => It.cu() || It.lu(),
isPushBlocked: () => {
const o =
It.isPushSupported() &&
"Notification" in window &&
null != window.Notification &&
null != window.Notification.permission &&
"denied" === window.Notification.permission,
i =
It.isPushSupported() &&
(!("Notification" in window) || null == window.Notification);
return o || i;
},
isPushPermissionGranted: () =>
It.isPushSupported() &&
"Notification" in window &&
null != window.Notification &&
null != window.Notification.permission &&
"granted" === window.Notification.permission,
Vn: () =>
It.isPushBlocked()
? { Wn: !1, reason: "blocked" }
: It.isPushSupported()
? It.isPushPermissionGranted()
? { Wn: !1, reason: "permissionGranted" }
: { Wn: !0 }
: { Wn: !1, reason: "unsupported" },
Yn: (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 It;