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:
What's the onboarding like to encourage users to subscribe to push notifications?

With @Pierce's OneSignal integration I have it so that the browser notification only appears to logged in users. So only members and newly registered users get a browser notification requesting push access. Or you can set it up so that just the bell appears in the corner of the screen, and the browser permission only appears if the user clicks on the bell to follow the subscription process.

Will there be some kind of automatic modal or request for logged in users?
Or will there be a notice criteria for unsubscribed users that we can use to display a custom notice in the bottom corner of the screen?
And if so, does that apply at a user level or per browser that the user uses? ie. desktop and mobile?

Is the push API smart enough yet to distinguish between sending desktop alerts vs mobile alerts kind of like with slack?
 
The onboarding is pretty basic, as it stands. It's just available from "Preferences" in the account menu.
 
I think, in fairness, I should probably also point out that Safari on macOS does have a push notification system. But it's a proprietary system that requires an Apple developer account and a fair amount of extra configuration. We won't be supporting this. It's just the principle of it really :)
I guess we can extend the PN system and add our own implementation for the proprietary Apple notification API?
 
Project Treble to the rescue. Treble is mandatory for official certified Androids and was introduced with Oreo. And Oreo already has a significant market share. :whistle: Really hope that will push an end to the fragmentation argument.

Looking forward to the push stuff. We've built our own solutions, but a native one would be far better. Looks great to me.
Did you just call ~20% a “significant market share”?

If I’m misreading the number and the pie chart, please do let me know how I’m meant to read it, because 20% is a tiny market share.

Also, 8.1 (released December 2017) has a 5.8% market share. It has taken them TEN MONTHS to reach an abysmal percentage of active devices. How in the world does that translate into an end to fragmentation? Fragmentation is just as awful of an issue as it was the last time I owned an Android device (back in the 2.3 / 4.0 days).

I’d be very interested in hearing how you can say Treble is ending fragmentation when 8.1 hasn’t even reached all the devices that is capable of 8.x.


Fillip
 
Just a note: In addition to the PHP 7.1 requirement, your site will need to be running over HTTPS with a valid SSL certificate, and you must have support for the GMP extension.
well Centmin Mod LEMP stack is ready though seems older GMP version
Code:
php --ri gmp

gmp

gmp support => enabled
GMP version => 6.0.0
What are GMP version requirements ? 6.0.0 enough or 6.1+
 
well Centmin Mod LEMP stack is ready though seems older GMP version
Code:
php --ri gmp

gmp

gmp support => enabled
GMP version => 6.0.0
What are GMP version requirements ? 6.0.0 enough or 6.1+
It's a good question. It doesn't appear to specify, so I assume that roughly any version should be sufficient.
 
Last edited:
The option to switch it off is displayed in the HYS post :)

Of course, HTTPS is recommended anyway, so I'd strongly recommend you consider that. Then if you did enable it, you'd then be able to leave it up to the users as to whether they want to enable notifications for their account or not. I'm certain some of them might find it useful, if not most.

Worth noting as well that it needs to be enabled "per-device". So some may prefer it on their mobile devices, and not on their desktop or vice versa.
 
Did you just call ~20% a “significant market share”?

If I’m misreading the number and the pie chart, please do let me know how I’m meant to read it, because 20% is a tiny market share.

Also, 8.1 (released December 2017) has a 5.8% market share. It has taken them TEN MONTHS to reach an abysmal percentage of active devices. How in the world does that translate into an end to fragmentation? Fragmentation is just as awful of an issue as it was the last time I owned an Android device (back in the 2.3 / 4.0 days).

I’d be very interested in hearing how you can say Treble is ending fragmentation when 8.1 hasn’t even reached all the devices that is capable of 8.x.


Fillip
Yep, 20% within a year or so is a significant market share, considering that the market is already fragmented as hell and oversaturated. Also considering that there won't be an upgrade for probably any L/M or lower devices (not even my N devices got an O upgrade :cry:), 20% within a year is quite a lot. That means that already 20% of new devices have been shipped and/or upgraded from N within a year.
It's not comparable to Apple right now, because Apple had this kind of environment for a very long time, but he, that's why I hope that Treble will be an even greater success than it already is.
8.1 has been skipped in favor of P in some cases btw (mostly low feature benefits since 8.1 focused on Go), but anyways, 8.0 has gotten the same security patches as 8.1 :whistle: So yea, 8.1 features might have been dropped in favor of P, but security patches are still on par.
And that's only Treble's first year. Besides that Go has just launched with 8.1, give it some time to establish, it's purpose is to kill ICS and lower. Pie got released recently aswell and is not even included in the chart, which again blocked 8.1.
 
It's not comparable to Apple right now, because Apple had this kind of environment for a very long time, but he, that's why I hope that Treble will be an even greater success than it already is.
Don’t get me wrong, I genuinely hope it does solve the fragmentation problem. If Android could reach the same stage iOS is at where “when Google says it’s out, it’s out”, and devices were updated for 3-5 years like on Apple hardware, I would be very happy for everyone running Android.

I just have such a hard time reading the facts in the way you are, since iOS 12 has been out for less than a month and already has over 50% market share (beating out iOS 11), it just seems like absolute madness that 15-20% is significant and calling Treble a success.

I guess in three years or so we’ll see how well it’s worked out, since by then most people should have replaced their 2017 devices that stopped getting updates, and would have bought at least an 8.0 device.


Fillip
 
It's a good question. It doesn't appear to specify, so I assume that roughly any version should be sufficient.
Hopefully gmp 6.0.0 is sufficient. The Remi RPM repository is used a lot by those who have their own CentOS 7 / other OS setup (ie don't use Centmin Mod) to update PHP from the default (which is still 5.4!) to the latest version (currently 7.2.10 so Remi does keep up with stable releases) but it only comes with gmp 6.0.0 rather than 6.1.2.

The gmp changelog only seems to suggest there's a few bugs fixed and a few new features, not sure if that would affect anything with the push notifications.

https://gmplib.org/gmp6.1.html
 
Push notifications was expected from some of us and finally we see it announced.
It is a valuable thing in the right direction, specially compared to the competitors of XF.
Great news today. Can't wait to see the other new things which will hopefully be on par with this news (one specific thing is also expected by this point).
 
Top Bottom