I am building a Django web app for status checking and need real-time background updates using the Web Push API. The web app will be accessed on both Android and iOS devices. To enable push notifications, I am using the Notification API to request user permission.
The implementation works on Windows, Linux, Android, and Mac, but it does not work on iOS. However, I do not want to convert my web app into a Progressive Web App (PWA). I need guidance on how to request notification permissions on iOS and ensure web push notifications function correctly.
Can someone help me find a solution to complete my project?
Current Implementation
I am using the following JavaScript code to request notification permissions from users:
document.getElementById('grant-permission').addEventListener('click', ()=> {
Notification.requestPermission().then(permission => {
console.log("permission:", permission);
if (permission === "granted") {
console.log("Notifications allowed!");
} else {
console.log("Notifications denied!");
}
});
});
Issue
This code works as expected on Windows, Linux, Android, and Mac. However, on iOS (Safari), it does not work. The permission prompt does not appear, and notifications are not allowed. What I Have Tried
- Tested on different browsers (Safari, Chrome) on iOS.
- Confirmed that Web Push API only works for installed PWAs on iOS.
- Ensured the code works on other platforms. Is there any way to request notification permissions and send push notifications without converting my web app into a PWA on iOS?
Any help or alternative solutions would be greatly appreciated!