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:
Are you using Chrome for Android on it or a different browser? What version of Android is on your device?
User agent string is: (Linux; Android 6.0; LGLS770 Build/MRA58K) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/38.0.2125.102 Mobile Safari/537.36

I only ever use the native android browser, not chrome or safari.
 
User agent string is: (Linux; Android 6.0; LGLS770 Build/MRA58K) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/38.0.2125.102 Mobile Safari/537.36

I only ever use the native android browser, not chrome or safari.
If that version is accurate, then that's the problem... Native Push for Chrome was added in Chrome version 42 for Android, likes like you're running Chrome 38.

Using Android 6.x you should be able to update your version of Chrome through the Google Play store unless you're locked into that version for some other reason.
 
If that version is accurate, then that's the problem... Native Push for Chrome was added in Chrome version 42 for Android, likes like you're running Chrome 38.

Using Android 6.x you should be able to update your version of Chrome through the Google Play store unless you're locked into that version for some other reason.
So.... even though the chrome browser itself is not in use, the system sees the version and on that basis decides you're not compatible? Not what browser you're actually logged in with?

I will try a chrome update, even though I never use it to access the web in any way.
 
So.... even though the chrome browser itself is not in use, the system sees the version and on that basis decides you're not compatible? Not what browser you're actually logged in with?
Not quite.

The built in Android browser in this case is basically Chrome 38.

That way predates the push functionality being added to Chrome itself.

Push notifications actually work back to Android 4, but you have to be using a version of Chrome (or a browser based on it) from within the last 3-4 years or so. Chrome 40-something so that version of the Android browser likely only missed out by a few months.
 
The built in Android browser in this case is basically Chrome 38.
That is odd. I have a separate chrome browser I can use, and it looks and functions completely different than the android browser I use. I wonder if I logged onto the forum with that, would it then like me without update. Going to test that theory.

But, if I update chrome, I can use push on my phone with the native browser?
 
I see what's going on now, you were right. Here's my UA now that i have logged into chrome and using it instead:

Mozilla/5.0 (Linux; Android 6.0; LGLS770 Build/MRA58K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Mobile Safari/537.36
 
I just upgraded to 2.1 on our forum and there is no option to enable push notifications under preferences. How to fix? I do have the option on Xenforo forum though.
 
For support, please post a new thread in the appropriate forum (or submit a ticket). We won't be routinely monitoring these threads for support.
 
This is why I run Google Chrome, Firefox, and Opera on my Macbook due to how Apple doesn't keep up with trends and therefore the end user loses out on great functionality. Anyway, I love the push notification feature and can't wait to include it with my add-ons once I come up with the money to renew my license. Forgot about it when I had money so now having to wait to get paid again if the government doesn't shut down again at the end of February. LOL

One last thing, I am loving the direction Xenforo is going and can't wait to see even more features in the future.
 
I'm sure this question has been asked, but have desktop browser notifications been explored? I just enabled a notification in chrome for a website and it works well.
 
Push notifications work on any device that supports them. This is essentially any browser on Windows, any browser on macOS (except Safari), any browser on Android and no browsers at all on iOS because Apple/WebKit are becoming the new Internet Explorer for the modern day.
 
It actually depends more on the browser version. As long as you are running a relatively recent version of Chrome, Firefox or Microsoft Edge, you should be fine. Theoretically this equates to push notifications working on Android 4.4 or above, just on the basis that most of those browsers only officially support that. In reality, some older versions of these browsers probably work on older versions of Android but it will probably only go as far back as Android 4.0 or 4.1.
 
But Google Chrome on Android needs to be running to receive Push Notif right?
In the first post, it says:

"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"
 
Top Bottom