1
0
puyopuyotetr.is/app/javascript/flavours/glitch/utils/notifications.ts

14 lines
380 B
TypeScript
Raw Normal View History

/**
* Tries Notification.requestPermission, console warning instead of rejecting on error.
* @param callback Runs with the permission result on completion.
*/
export const requestNotificationPermission = async (
callback: NotificationPermissionCallback,
) => {
try {
callback(await Notification.requestPermission());
} catch (error) {
console.warn(error);
}
};