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:
I’m not surprised in the slightest. I think I first started talking about iOS push notifications when we were waiting for iOS 8 to be revealed at WWDC 2014.

I want to come up with something but I don’t know what, yet. Don’t get your hopes up. First thing I want to try is actually opening a dialog with Apple/WebKit engineers. I recently had a disagreement with a couple of them on Twitter so that’s a start but I need to do something more constructive.
 
I’m not surprised in the slightest. I think I first started talking about iOS push notifications when we were waiting for iOS 8 to be revealed at WWDC 2014.
It will be one of those things where as soon as you put too much effort into doing something (like spending the effort implementing Apple's kludgey web push for macOS Safari), they will finally do it.

Happened to me with XF's image proxy feature... wanted it for a long time, figured it would never be part of core so I finally did it myself. 4 days later you guys did the "Have you seen?" for upcoming image proxy feature... hah

I feel like Apple has no choice but to implement native Push API... however they still haven't, so maybe it's just the "want" part of my brain overriding the logic part? Not sure... crazy to me they still haven't done it.
 
Not sure... crazy to me they still haven't done it.
IMHO not at all. Push is an important feature on mobile devices, if they open that up for websites (instead of keeping it exclusively for native iOS apps) the importance of having native iOS apps will shrink.
 
IMHO not at all. Push is an important feature on mobile devices, if they open that up for websites (instead of keeping it exclusively for native iOS apps) the importance of having native iOS apps will shrink.
Not sure Apple places a ton of value to apps that are free/they make no money from serving no purposes other than to serve up push notifications.

I'd think there is some value for end user experience where users are like, "What? Android phones let me get push notifications from websites?" ...and people on the fence between iOS and Android switch to Android because missing features on iPhones.
 
I’m not surprised in the slightest. I think I first started talking about iOS push notifications when we were waiting for iOS 8 to be revealed at WWDC 2014.

I want to come up with something but I don’t know what, yet. Don’t get your hopes up. First thing I want to try is actually opening a dialog with Apple/WebKit engineers. I recently had a disagreement with a couple of them on Twitter so that’s a start but I need to do something more constructive.

Hopefully MacRumours - A large Xenforo Apple based forum might be able to get in touch with the right people - Especially as 1.5 is no EOL
 
@Chris D

Invision community admin here, facing same issue. Wanted to come over to see how xenforo is handling, as this is a common problem for any of us trying to keep the forum world alive.

I had some dialogue with one of the apple PWA dev's, specifically regarding https://medium.com/dev-channel/prog...n-ios-12-2-beta-1-build-16e5181f-a18cd05ca361

Their response on whether they would implement:

There's lots of things on that list that we'll do over time. Can't make specific promises about future products. If you want to provide info about Push API, you can comment on the bug. Preferably concrete use cases, especially things you are doing or plan to do with it.

The bug referenced is here: https://bugs.webkit.org/show_bug.cgi?id=182566 [Edit: I see this was also linked in an earlier post. However, more visibility can't hurt!]

I know the reality is that this is probably a strategic apple decision to not start work on push API support, but in the interest of not leaving any stone unturned, it would be awesome if the xenforo community could join efforts and submit detailed (and numerous!) feedback to https://bugs.webkit.org/show_bug.cgi?id=182566 (as well as the other bugs/feedback channels listed in the medium article) with specific, detailed examples of how push notifs would be used as part of a PWA.

It's a frustrating position where it feels like we're all yelling into the abyss, but may as well take advantage of these feedback channels.

Again (although I sincerely doubt it's a good faith position) the devs responsible for implementation are acting as though they required detailed, concrete use case examples (as if it isn't glaringly obvious), so anyone who wants to submit, please try to avoid "+1 I need this" and provide as much detail to your feedback as you can.

If you want Push Notifications support, chime in on WebKit Bug 182566.
If you want Background Sync support, chime in on WebKit Bug 182565.
If you want Storage Estimation support, chime in on WebKit Bug 185405.
If you want Web App Manifest icons for PWAs, chime in on WebKit Bug 183937.
If you want Add to Home Screen support for PWAs, chime in on WebKit bug 193959.
If you want Web Share Target API support, chime in on WebKit bug 194593.
If you want Web Share API — Level 2 support (file sharing), chime in on WebKit bug 198606.
If you want Navigation Preload API support, chime in on WebKit bug 182852.

Also, as a final thought, I'm not sure how much communication there is between the development teams for Xenforo, Invision, NodeBB, Discourse, Vanilla, etc. etc., but this is one of those topics where forming a lobbying group of developers where you can aggregate the number of users across all platforms and deliver some consistent messaging would be really helpful IMO. Any victories we can make with PWA in iOS ultimately serves to keep all of our communities alive and able to compete with other closed platforms, as ultimately user engagement on mobile through notifications (and in the case of iOS, the complete lack thereof) is going to make or break many of us.
 
Last edited:
Off topic? Wrong place? But how do you control how the push notification "prompt to enable" is displayed? Some users complaining that is annoying them.
 
Off topic? Wrong place? But how do you control how the push notification "prompt to enable" is displayed? Some users complaining that is annoying them.
The time it takes them to complain is much more time than simply choosing an option for push notifications and never see it again.
 
Off topic? Wrong place? But how do you control how the push notification "prompt to enable" is displayed? Some users complaining that is annoying them.
I believe they have to enable it. I know that for me, when your site upgraded, my browser asked me if I wanted to allow push notifications. So this is a user-end browser option. It's not overtly controlled by Xenforo.

For instance, users on Firefox can click the "i" in the circle just to the left of the address bar and turn push notifications off. Chrome and others have a similar function.
 
If the user wasn't presented with the option, 99.99% would never find the setting and enable it, so might as well disable it altogether if you want to do that.
 
Top Bottom