Get notified of new strips through push notifications (BETA)
This Browser's Subscription Status
About
In these days of short attention spans and people expecting machines to do all the work for them, I reckon it would make sense to provide web push notifications when a new S.O.N.A.I.S. webcomic strip is published. It has almost costed me my sanity to implement this, but here it is.
The BETA label means this is likely to contain bugs and not behave according to my quality standards. Given the current state of how web push notifications are handled across different platforms, I'm afraid I will not be able to remove the BETA label in the foreseeable future, if ever.
Instructions
In a nutshell: open this page on the device where you want to receive the notifications. On mobile devices, it is mandatory (in iOS), or at least recommended, to install this as an ‘app’ on your home screen (a so-called PWA, more info below). On desktops/laptops, I recommend not to deploy the PWA.
If you need/want the PWA, open it and then press the Subscribe button inside it. Otherwise, just press the Subscribe button in your regular browser.
Unfortunately the current state of push notifications is still shrouded in black magic and arcane rituals—not only for developers, but also for users. However, I expect anyone who reads this comic to be geeky enough to figure it out. If you are unfamiliar with push notifications, I'm sorry to say that you will have to read through the entire pile of text below, to have any chance of the notifications working and not breaking after a while. Welcome to the Internet anno 2024.
Push messages are registered for the specific browser on the specific device where the Subscribe button is pressed. For instance, if you want the messages to show up on your smartphone, navigate to this page on that phone (and if needed/desired, do the PWA ritual as described below), and press the button there.
On iOS Safari (iPhones and such), you need at least iOS version 16.4, it won't work in older ones. Even in compatible versions, this will not work directly in the Safari app. There, you must first install this as a ‘PWA’ (Progressive Web App, an icon on your home screen).
To do this, press the ‘Share’ button that is either in the top right of the display or at the bottom (scroll up to make it appear), and then choose “Add to Home Screen.” Then open this newly installed ‘app,’ and follow the instructions inside it.
Even on Android or other non-iOS mobile devices, I recommend deploying the PWA, because it is convenient. You may get a prompt to deploy the PWA upon opening this page. If not, it can be installed through the browser menu in a similar way as described above for iOS. First decide whether you want the PWA or not, and only then press the Subscribe button either inside the PWA or in your regular browser tab. Do not try to do both, or things may get hairy.
The registered browser app must stay “open” for the messages to appear, although you don't need to keep any of this website's pages open (notifications are handled by a service worker that stays present in the background). After rebooting your device, it is recommended to re-open the PWA or browser app to ensure you will keep receiving the messages.
If you want the messages on multiple devices, you will need to subscribe each of them, but each device will be unaware that you already opened a message elsewhere, so I would suggest picking only your most convenient device. If you want to migrate to a new device, unsubscribe the old one and repeat the subscription process on the new one.
Remarks
This requires a fairly recent browser to work. If you are using Chrome or Firefox on any non-antique device, it should work. Safari on iOS works from version 16.4 onwards. Safari in MacOS works from Ventura (13.0) onwards (but, see remarks below).
The local notification test button creates a fake notification to see if at least that part works. It does not test receiving messages from the server. The only way to verify that, is to wait for the next strip to be published. It is not abnormal for the first message to not appear, so don't panic until you have seen at least 2 new strips on the S.O.N.A.I.S. website without being notified.
Safari in (a compatible version of) MacOS does does have one upside: you should still receive notifications even when Safari is “closed*.” However, the downside is that you may also have to jump through extra hoops here, see the troubleshooting section below.
(* spoiler: Safari never really closes. Apple is now doing exactly what they accused Microsoft of back in the days: making their browser too intertwined with the OS. How times have changed… or not.)
This comes without any promises. Use at your own risk. Reliability depends on Google's FCM, my ability to work around other people's (and my own) bugs, alignment of the stars and planets, and the degree to which certain companies succeed in pushing their disgusting agendas rife with dumb short-sighted greedy policies aimed at hurtling us all back to the pre-internet era.
This works without logins or authentications. I opted to implement the messages through Google's FCM, a.k.a. Firebase service. The FCM server keeps a unique ID for this particular ‘app’ on the browser where the Subscribe button is pressed. If you want to have this ID wiped from the servers, it can be done, but you will have to contact me. In general it is pointless to be paranoid about this, this little bit of data is of no use to anybody and will vanish a few months after unsubscribing anyway.
Don't try to go all Zhang on this to see if you can break it with typical QA practices like hitting the buttons like a madman. The server might decide you behave like a bot, and trigger an automated ban. Also do not try to install the PWA multiple times even if it seems possible. Any deviation from the instructions is at your own risk.
Troubleshooting
Push message subscriptions are fragile. Expect notifications to break as soon as you change something about this site's notification permissions in your browser's preferences, or if you indiscriminately delete site data. You should check the subscription from time to time. If you don't use a device for a long time (probably more than a month), it will no longer receive messages. If you suspect notifications are broken, come back to this page, or open the PWA if installed, and hit the ‘Subscribe/Refresh’ button.
In iOS Safari, at some point you may start seeing duplicate notifications. I will apologise in advance: there is nothing I can do about this. Apple has done their utmost best to screw developers when it comes to notifications. Safari does not honor the notification ‘tag’ concept. Apple finds it paramount that the user sees every single push message ever received, even outdated ones or duplicates caused by bugs in the push server. Due to the nature of the duplicates bug, unsubscribing and re-subscribing will not fix this, in fact it could make it even worse, so don't. With some luck, the duplicates will go away again after a while. Again, no promises.
Also in iOS Safari, you may end up on a blank page after opening a notification and pressing ‘Done.’ This is yet another Apple bug. The only remedy is to restart the whole notification app: do the weird gesture to get an overview of open apps, swipe it upwards to close it, then re-open it. To reduce the risk of this bug occurring, keep the app open.
If you are using Safari in MacOS, and you get an error about ‘PushManager’ when clicking the Subscribe button, this is perfectly “normal,” because Apple. The remedy is to quit Safari and reopen it—don't ask why: Apple. Then click the Subscribe button again, and it might work; if not, repeat this process a few times. If it keeps failing, why not try Chrome or Firefox instead? You might like it.
In recent versions of Chrome, you may end up in a situation where it seems as if you denied notification permissions, even if you didn't. This is a total mess and I might try to debug this at some point. Until then, the proper way to escape this mess is unclear, but unsubscribing (if need be, using the ‘force’ option from Geek Mode), entirely uninstalling the PWA if installed, and deleting any notification settings for www.dr-lex.be in your browser's settings, has a decent chance of fixing it.
Some devices may postpone showing the notification when they are in airplane/silent mode, even if WiFi is enabled.
Why is this so complicated?
If this all seems terribly complicated and confusing, that's because it is. The web push ‘standard’ is an organically grown atrocity of which every device/browser vendor has a different interpretation. And, you don't even want to know what it took to get all this working from a developer point-of-view. When I started working on this, I thought it would be relatively straightforward to implement, but oh boy, was that a naïve idea. A guide on StackOverflow summarises it well:
I almost lost my sanity on this, but now I do have something that should work… usually. Someday, I might write a guide that tries to summarise all the wisdom I have gathered, because the only things I have found so far were piecewise bits of info. Nobody gives a good overview of all the pitfalls when implementing something like this in a way that goes beyond doing the typical thing of cluelessly deploying an overly complicated framework and then sprinkling it with some magic JSON copied from a YouTube video or ChatGPT.
There seem to be proposals to make web push messaging less of a pain to implement and use, but for the time being, this is how it is.