import {useEffect, useRef, useState, React} from "react";
const useNotification = (title, options) => {
if (!("Notification" in window)) {
return;
}
const fileNotif = () => {
if (Notification.permission !== "granted") {
Notification.requestPermission().then((permission) => {
if (permission === "granted") {
new Notification(title, options);
} else {
return;
}
});
} else {
new Notification(title, options);
}
};
return fileNotif;
};
export default () => {
const triggerNotif = useNotification("Hello", {body: "this is options"});
return (
<div className="App">
<button onClick={triggerNotif}>Hi</button>
</div>
);
};