Created
October 21, 2025 19:33
-
-
Save thecompez/592d59b52b4e6b3d6897b3d9920ec862 to your computer and use it in GitHub Desktop.
Notify Usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Sends a test notification by calling the backend endpoint. | |
| * Uses the notificationDetails passed from the frameAdded event. | |
| * @param {Object} notificationDetails - An object containing { url, token }. | |
| */ | |
| async function sendTestNotification(notificationDetails) { | |
| try { | |
| // Send a POST request to store the notification details. | |
| const storeResponse = await fetch("send-notification.php", { | |
| method: "POST", | |
| headers: { "Content-Type": "application/json" }, | |
| body: JSON.stringify(notificationDetails) | |
| }); | |
| const storeData = await storeResponse.json(); | |
| console.log("Notification details stored in file:", storeData); | |
| // Only trigger the test notification if storage was successful. | |
| if (storeData.status === "success") { | |
| const notifyResponse = await fetch("send-notification.php"); | |
| const notifyResult = await notifyResponse.text(); | |
| console.log("Send notification response:", notifyResult); | |
| } | |
| } catch (error) { | |
| console.error("Error in sendTestNotification:", error); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment