I have read everything I can read in these forums on push notifications, and I cannot figure out why I cannot get them to work. I have not installed the push notifications plugin because the forums say that they are included in Discourse Core. Live notifications are enabled in preferences. Does this feature work without installing the plugin? Also, the user prompt at the top of the page that is supposed to be there is not despite enabling the prompt in settings.
This is the error I see in my logs:
TypeError: Failed to construct 'Notification': Illegal constructor. Use ServiceWorkerRegistration.showNotification() instead.
at o (https://caseclosed.world/assets/application-5a08d7796085bdd3031b0fbc17dea424f5c6cd21f021924582fcb0200bd8325f.js:12:23300)
at https://caseclosed.world/assets/application-5a08d7796085bdd3031b0fbc17dea424f5c6cd21f021924582fcb0200bd8325f.js:29:4479
@supermathie perhaps that is what I am missingâŚthe mobile PWA. I will give that a try. Do users also need to âwatchâ categories, or can that field in settings remain blank? I am trying to simplify the process for users to enable notifications. I was hoping that by me setting certain categories to watch by default in settings that they would not have to take that extra step of watching categories. As it is, they have to go to their preferences to enable live notifications, and now it is looking like they need to download the PWA. Still, I am bewildered as to why the user prompt is not appearing at the top of the page.
@Stephen it is funny you mention that, because âforce Httpsâ does not appear in my settings. I was running a test Discourse forum on another domain and with another host before launching a new domain with a new host. I no longer see the âforce httpsâ in the settings. Https is active, though, or at least that is what the url indicates.
I followed the same stepsâŚI thought the change was due to a Discourse core update, and until now I did not pay much attention to the issue. The only difference was the new domain, and the new host. I am using the Material Design Theme with custome header links and discourse social share components. These are the plugins installed:
I downloaded the Discourse app, selected my domain when prompted to choose a forum, and added it to my home screen. I am signed in on the PWA and live notifications are enabled. I am attaching a little video that shows what I did.
TypeError: Failed to construct 'Notification': Illegal constructor. Use ServiceWorkerRegistration.showNotification() instead.
at https://example.com/assets/application-[spoiler]4f3f9a6090af98121b9336075c31d028a231c99ffbd60bb8ae119baff3133d88.js:12:27295[/spoiler]
at f (https://example.com/assets/ember_jquery-[spoiler]a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:17:29538)[/spoiler]
at T (https://example.com/assets/ember_jquery-[spoiler]a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:17:30915)[/spoiler]
at https://example.com/assets/ember_jquery-[spoiler]a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:17:31429[/spoiler]
at t.invoke (https://example.com/assets/ember_jquery-[spoiler]a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:16:6937)[/spoiler]
at e.t.flush (https://example.com/assets/ember_jquery-[spoiler]a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:16:5930)[/spoiler]
at e.t.flush (https://example.com/assets/ember_jquery-[spoiler]a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:16:7980)[/spoiler]
at e.r._end (https://example.com/assets/ember_jquery-[spoiler]a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:16:12654)[/spoiler]
at MutationObserver._boundAutorunEnd (https://example.com/assets/ember_jquery-[spoiler]a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:16:8905)[/spoiler]
I can provide you the full links if it helps you, but I blurred them to the public. Let me know if you need the full urlâs and I would be happy to provide. Thanks again for your help with this.
I just realized you said that my forum prompts you to âadd itâ on your Android. Do you mean to say that my forum is prompting you to enable notifications? If so, that is very interesting since it does not prompt me on my android, yet the meta.discourse forum DOES prompt me. I am really scratching my head on this. The meta.discourse is prompting me on my desktop, but my forum is NOT prompting me on my desktop. I have tried Chrome and Edge browsers, and both give me the same result.
There is a lot of confusion here in this topic. Letâs start over:
Discourse Hub App
Using discourse.org hosting: You can receive push notification when you add the hosted site to the Discourse Hub app, be it Android or iOS.
Not using discourse.org hosting: You wonât get push notification from the Discourse Hub app.
Android Google Chrome
You can enable push notification from the browser. You will be prompted to do so in a banner after posting your first reply and having TL1. You can also enable it anytime in your profile. You donât need to add the app to the homescreen to do so (for now).
Copy thatâŚregarding the Discourse Hub app, you clarified why I am having difficulty with the app. Regarding Android Google Chrome, I was using a different browser on my Android, which explains that issue. I can confirm now that I get the prompt when using Android Google Chrome.
So, it is all starting to make sense. I am wondering if I can bother you for some direction now. Being that I do not use discourse.org hosting, what do you recommend I do if I want to provide push notifications in other browsers on Android, or to iOS? I am guessing I can install the discourse plugin for desktop notifications to resolve that issue. I was hesitant to do that at first because I understood, from the forums, that discourse core already provided push messaging, and therefore a plugin was unnecessary. Feel free to shoot me straight on this.
I have removed many of the plugins I was using, and I can confirm I no longer get that error. I will add back the plugins, one by one and over the course of a week, to determine which plugin causes that error. Thank you for catching that it is due to a custom plugin. These are the plugins I am currently using:
It does work fine on Firefox on Android, but we donât support that browser. It works because it adheres to the same web standard every modern browser implements.
iOS Safari browser donât implement the Web Push Notification web standard, so there is nothing we can do here.
That plugin only âunhidesâ the web push button for desktop browsers. Support is still the same, Chrome, Firefox & Edge, on the Desktop and Android. We only hide this button on desktop because most people donât want notifications when the browser is closed on the desktop (and you are playing a game, fullscreen and dies because of the notification lag ).