mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-14 00:53:04 -04:00
NotificationAPI: Correctly request browser permissions
This commit is contained in:
parent
2b0c25b45c
commit
68055977d2
2 changed files with 16 additions and 2 deletions
|
@ -76,8 +76,15 @@ function shouldBeNative() {
|
|||
return false;
|
||||
}
|
||||
|
||||
export function showNotification(data: NotificationData) {
|
||||
if (shouldBeNative()) {
|
||||
export async function requestPermission() {
|
||||
return (
|
||||
Notification.permission === "granted" ||
|
||||
(Notification.permission !== "denied" && (await Notification.requestPermission()) === "granted")
|
||||
);
|
||||
}
|
||||
|
||||
export async function showNotification(data: NotificationData) {
|
||||
if (shouldBeNative() && await requestPermission()) {
|
||||
const { title, body, icon, image, onClick = null, onClose = null } = data;
|
||||
const n = new Notification(title, {
|
||||
body,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue