XF 2.1 Push notifications

Welcome to the first of our "Have you seen...?" series for XenForo 2.1. We've got a lot to show you over the course of the next few weeks so you may well be hearing from us quite frequently... To ensure you're kept up to date, we strongly recommend clicking the "Watch forum" link here and enabling email notifications if you haven't done so already 🙂

But first...

The first thing that we should announce before we get started is something which we have talked about over the last year which is related to the minimum server requirements of XenForo 2.1. XenForo 2.0 currently requires a minimum of PHP 5.4, but with XenForo 2.1 we are increasing this to a minimum of PHP 5.6. Now, PHP 5.6 is still pretty old by today's standards, so you may be interested to understand why we have settled on that as our new minimum PHP version.

The answer is fairly simple, in that we are essentially trying to strike a balance between the features in PHP that we need to use, the requirements of third-party packages that we include with XenForo, and ultimately the common PHP versions that customers are using on their servers. Since XF 2.0.2 we have been keeping track of this, and these are the current results:

1539019830210.webp

To the one customer who is running PHP 7.3 Alpha I sincerely hope you are doing so in a test environment 😉
As you can see, it seems like a fairly safe bet for us to consider leaving behind PHP 5.4 and PHP 5.5 as that amounts to only 6.5% of the total customer base. One could argue that PHP 7.0 would be an ok target too as the total PHP 7.x usage is at 55.3% but leaving behind a total of 44.7% of the total customer base seems unreasonable at this point. We'd strongly recommend everyone consider upgrading to PHP 7.2 as soon as possible.

That all said, we have mentioned previously that there is one feature which will require a minimum version of PHP 7.1 to use...

Push it real good...

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.
Sorry, I couldn't help myself! 🙂

That's right, we're kicking off our XF 2.1 series of HYS threads by announcing that our most popular suggestion is implemented! Let's first look at how to set it up.

1539022286792.webp

If the above browser/device requirements are frustrating then please direct your complaints to @WebKit on Twitter!

So, yes, first and foremost, you will need PHP 7.1 to enable this functionality. This enabled us to implement the functionality in a way that is compatible with as many browsers as possible, including Microsoft Edge on Android and Windows.

In addition to this, your site must be running over HTTPS with a valid SSL certificate, and you must have support for the GMP extension.

Unfortunately for reasons beyond our control (read: it's Apple's fault) the list of supported devices/browsers notably exclude Safari on macOS and any iOS-based browser. This functionality is made possible by making use of a number of APIs including the Push API and Notification API which most browsers support already.

On supported devices, the process looks something like this:

21push1.gif

You can also see that, just like alerts, we have provided a mechanism for you to be able to opt out of receiving certain push notifications. You may want to get forum alerts for everything, but only be notified by your browser for the things you find important.

The content of a push notification will be a slightly stripped down version of the default alert template. A brief note for developers; although there is code which will automatically convert HTML to a text-only version of the notification, the preferred method would be to create specific push template for each content type and action, and these will look similar to this:
HTML:
{{ phrase('x_quoted_your_post_in_thread_y', {
   'name': $user.username ?: $alert.username,
   'title': prefix('thread', $content.Thread, 'plain') . $content.Thread.title
}) }}
<push:url>{{ link('canonical:posts', $content) }}</push:url>

As you would expect with push notifications, you do not necessarily need to be viewing the forum when the notification is received, nor does the browser even need to be active, as demonstrated here:

21push2.gif

Naturally, clicking on the notification will take you straight to the content.


Alert read marking

Going straight to the content from wherever you are on your device is certainly convenient, but given that push notifications essentially represent forum alerts, it would be somewhat inconvenient to have to mark those as read too.

Therefore when you now visit content which you have previously been alerted to, the corresponding alert(s) will now be automatically marked as read.


"But I have an Apple device, will you support push notifications another way...?"

Unfortunately, this is unlikely. Although Apple devices represent a significant number of mobile users, the current approach other browser vendors are taking is standardised (meaning Apple devices could be nearly automatically supported in the future), free and seamlessly integrated with your browser. Any other approach, be that a separate app, or a third party service would, frankly, be a sub-par (and potentially expensive!) experience.

The overall solution is simple, but it is down to Apple/WebKit to take on board and implement. According to the WebKit Feature Status page, if there are any features missing you can reach out to @webkit on Twitter or contact the webkit-help mailing list. Consider doing that today to help them understand why push notifications are important for your forum 🙂


And, sadly, that brings the first HYS for XF 2.1 to an end! But don't worry - as mentioned earlier we have lots more to get through 🙂 And we may well see you for that fairly soon 😉
 
Last edited:
😂

Don’t “Sad” me! 😉

You have to bear in mind that sending push notifications to guests isn’t exactly trivial.

We literally have no existing concept whatsoever that allows a guest to follow or watch any content. It’s not just a case of switching it on for guests and that’s it. It would essentially be a huge overhaul to the existing alert and watch systems to allow it and just to be clear that is way beyond the scope of 2.1 at this point.
 
😂

Don’t “Sad” me! 😉

You have to bear in mind that sending push notifications to guests isn’t exactly trivial.

We literally have no existing concept whatsoever that allows a guest to follow or watch any content. It’s not just a case of switching it on for guests and that’s it. It would essentially be a huge overhaul to the existing alert and watch systems to allow it and just to be clear that is way beyond the scope of 2.1 at this point.

Is the on-boarding message turned on here?
 
We literally have no existing concept whatsoever that allows a guest to follow or watch any content. It’s not just a case of switching it on for guests and that’s it. It would essentially be a huge overhaul to the existing alert and watch systems to allow it and just to be clear that is way beyond the scope of 2.1 at this point.
Allowing custom messages to be sent to guests would be a great first step. That's what OneSignal does.
Basically what would be needed is:
  1. Guest gets Modal to allow sending of Push notifications.
  2. Admin sends Push notification through Admincp: (/admin.php?users/alert) to Unregistered Users.
  3. Guest Receives Push notification.
If XF support this, then we can uninstall OneSignal and replace it with XF Push. Without a possibility to onboard guests, we loose tens of thousands of subscribers.
 
I see it. Works great. Is logging out supposed to disable push notifications?

I noticed everytime I relog on my Android, it asks me.
Yeah this is a specific thing we do. Problem is if we don't do that then on a shared browser/computer you would continue to get push notifications delivered there when you're logged out. Potentially even after someone else logs in. So we just kill the subscription as soon as the user ID changes to 0 to avoid any sort of data leakage/privacy issues.
 
Allowing custom messages to be sent to guests would be a great first step. That's what OneSignal does.
Basically what would be needed is:
  1. Guest gets Modal to allow sending of Push notifications.
  2. Admin sends Push notification through Admincp: (/admin.php?users/alert) to Unregistered Users.
  3. Guest Receives Push notification.
Yep, still requires extensive changes, unfortunately :)
 
I see. Thanks for explaining. We will keep using OneSignal until we can onboard guests to XF Push.
The alert system wouldn't need to be overhauled but the big issue is that there is no precedent, so a lot of experimentation and time required. By the end of MS I began to set the foundations for a guest system.

It is doable, but it is a large undertaking and I don't think it's high on the list of priorities.
 
If I'm using CloudFlare but I don't explicitly have https set up, what would I need to do to get notifications working? An idiot's guide would be useful ;-)
 
Well to be honest it should just be a case of clicking the enable button in options in terms of the software itself.

Outside of that, configuring SSL and upgrading PHP / adding the GMP extension (if needed) is beyond the scope of support.

That said, if you’re using CloudFlare and your site isn’t currently using SSL then I’m pretty sure it’s easy to do with their “Flexible SSL” thing. It enables SSL between your users and their proxy server which is sufficient for push notifications to work.
 
Well to be honest it should just be a case of clicking the enable button in options in terms of the software itself.

Outside of that, configuring SSL and upgrading PHP / adding the GMP extension (if needed) is beyond the scope of support.

That said, if you’re using CloudFlare and your site isn’t currently using SSL then I’m pretty sure it’s easy to do with their “Flexible SSL” thing. It enables SSL between your users and their proxy server which is sufficient for push notifications to work.

Yeah it's the latter bit I hadn't really heard of before until you mentioned it. I'll talk to our hosts (Nimbus) at some stage about it.
 
Mhmm...got my first alert, nice. But it doesn't send me anywhere nor opens it my browser. S8, Android 8, Firefox. Anyone else?
Clicked on a notification and it sent me to the thread.

I'm on a Mac and XenForo's notifications only appear while Firefox is open. If they worked on Safari, would that be the default behavior?
 
In case you miss the suggestion thread we have now implemented an improved on-boarding approach for push notifications. It isn't a modal prompt (as such) as we feel that's a little invasive but instead a bottom fixed banner which invites the user to enable push notifications. If they wish to dismiss this, then they can do so by clicking the "X" in the top right corner. At this point, they're asked once more to enable, or otherwise "Ask later" or "Don't ask again" (for this device).
I believe a little more thought/process is required on this prior to GA release. Items to be addressed;
  • When the fixed banner is displayed, there is no link/modal functionality (eg. help icon with tooltip, or hyperlink to help page) to explain what push notifications are.
  • When you click the hyperlink to 'enable push notifications' in the banner, you get no feedback or response. The banner simply disappears. If a user wasn't sure what the hyperlink was or meant (thinking that it led to an explanation) then they'll assume it's broken. The lack of feedback/response will possibly lead a user that does know what it is/means, to believe it's broken or didn't work too.
  • If you had push notifications enabled, and then disable it from /account/preferences, the fixed banner immediately appears. Should probably assume either "Ask Later" or "Don't ask again" when disabling.
 
Last edited:
When the fixed banner is displayed, there is no link/modal functionality (eg. help icon with tooltip, or hyperlink to help page) to explain what push notifications are.
The UI used and language is consistent with many other sites which offer similar functionality. Some do not do any more than the bare minimum built-in browser permission prompt, like Facebook:

187780


When you click the hyperlink to 'enable push notifications' in the banner, you get no feedback or response. The banner simply disappears. If a user wasn't sure what the hyperlink was or meant (thinking that it led to an explanation) then they'll assume it's broken. The lack of feedback/response will possibly lead a user that does know what it is/means, to believe it's broken or didn't work too.
If you haven't already previously given permission for push notifications (which you have, because you're testing stuff) then you would see the browser permission prompt (like above) when clicking "Enable push notifications". We have added a confirmation now however by way of a notification being displayed (on the current device you've just subscribed with).

If you had push notifications enabled, and then disable it from /account/preferences, the fixed banner immediately appears. Should probably assume either "Ask Later" or "Don't ask again" when disabling.
We disable the push call-to-action for the current session now after push has explicitly been disabled.
 
@Chris D

Hi Chris,

I want to know that is there any option for admin to send a notification through push to those members who have been enabled this feature?
for instance, I want to call members for announcing something important.
 
Top Bottom