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 is apple reluctance to adhere to the standards? Is it apple trying to do things their way and stay inside their ecosystem?
 
What is apple reluctance to adhere to the standards? Is it apple trying to do things their way and stay inside their ecosystem?
It’s probably a mix of things ranging from conspiracy theories to resources required.
  • Not supporting web push on iOS means more people will create iOS apps just for push functionality.
  • All browsers on iOS are really wrappers for WebKit... meaning Chrome or any other browser for iOS can’t support push API either. So browser competition isn’t a thing for them.
  • Not a high priority because if you are an iPhone user, the lack of web push isn’t going to be enough to make you switch to Android.
  • This is probably the biggest issue... Service Workers are required for Push API, which means your iOS device will need to have a constantly running process which will not be good for your phone’s battery life. Probably what we’ll see when it finally becomes available is some sort of hybrid system where the Service Workers aren’t actually running all the time, and instead get an invisible push notification via the normal push system to wake them up and do their thing when needed. So for Apple it will be more work to do it more efficiently than normal which would just sacrifice overall battery life for web push.
Service Workers are. New addition to Safari, so at least they are slowly moving in the right direction.
 
Oh yes it is...

iOS 13 is make or break for me. I have until October. My new phone will either be the latest iPhone or something else entirely.
Haha true, I was thinking about it after I wrote it and everyone has a threshold to switch. I’m not quite there yet, but it’s definitrly becoming a bigger and bigger annoyance. I hope they include it with iOS13, but not holding my breath... also been hoping for the last 5 iOS versions.
 
Same. Definitely around iOS 8 IIRC I was starting to get frustrated.

I keep pestering Craig Federighi and WebKit engineers by email. At this point they may just be ignoring me and withholding the feature out of spite ;)
 
This is probably the biggest issue... Service Workers are required for Push API, which means your iOS device will need to have a constantly running process which will not be good for your phone’s battery life. Probably what we’ll see when it finally becomes available is some sort of hybrid system where the Service Workers aren’t actually running all the time, and instead get an invisible push notification via the normal push system to wake them up and do their thing when needed.
I think that's actually how it has been designed and how works on Android: Service workers don't run all of the time. Instead, Android devices receive web push notifications through Google's push infrastructure (the same which is used by native apps) and Android starts the corresponding service worker on demand. That's why all of the service worker code exists in event handlers ("install", "push", "notificationclick") and you cannot rely on global state (global variables) because they could vanish any time. So if a push notification is received, Android launches the service workers, runs its "push" event handler and then shuts down the service worker again (possibly after a small grace period because it may be likely that the user immediately clicks the notification which would cause the "notificationclick" event handler to be executed). So I don't think that service workers used for push notifications have a noticeable impact on battery life (if done right). But still, they are quite complex beasts.

All your other points are spot-on, I'd say. :)
 
It’s probably a mix of things ranging from conspiracy theories to resources required.
  • Not supporting web push on iOS means more people will create iOS apps just for push functionality.
  • All browsers on iOS are really wrappers for WebKit... meaning Chrome or any other browser for iOS can’t support push API either. So browser competition isn’t a thing for them.
  • Not a high priority because if you are an iPhone user, the lack of web push isn’t going to be enough to make you switch to Android.
  • This is probably the biggest issue... Service Workers are required for Push API, which means your iOS device will need to have a constantly running process which will not be good for your phone’s battery life. Probably what we’ll see when it finally becomes available is some sort of hybrid system where the Service Workers aren’t actually running all the time, and instead get an invisible push notification via the normal push system to wake them up and do their thing when needed. So for Apple it will be more work to do it more efficiently than normal which would just sacrifice overall battery life for web push.
Service Workers are. New addition to Safari, so at least they are slowly moving in the right direction.
Informative, thanks
 
As a webmaster who also has published an App that is a sidekick to their website I still chuckle at this poor decision by Xenforo. I fully admit Apple is a royal pain and I fully admit Apple could bend, but I also know Apple has created a setup that greatly rewards those who put forth the effort and delivers a quality product. While our App has roughly the same amount of downloads for Droid and iOS we see a very noticeable increase in subscriptions for iOS.

While some may see this as Xenforo trying to save web owners effort and money (and I understand this mindset) I personally see it as a disservice. There’s a HUGE goldmine here that IMHO Xenforo sites are missing out on. I know iOS users would fork over the cash to make it worth a website’s time/effort to make it happen......just don’t ask me how short of an App.
 
As a webmaster who also has published an App that is a sidekick to their website I still chuckle at this poor decision by Xenforo. I fully admit Apple is a royal pain and I fully admit Apple could bend, but I also know Apple has created a setup that greatly rewards those who put forth the effort and delivers a quality product. While our App has roughly the same amount of downloads for Droid and iOS we see a very noticeable increase in subscriptions for iOS.

While some may see this as Xenforo trying to save web owners effort and money (and I understand this mindset) I personally see it as a disservice. There’s a HUGE goldmine here that IMHO Xenforo sites are missing out on. I know iOS users would fork over the cash to make it worth a website’s time/effort to make it happen......just don’t ask me how short of an App.
Except iOS install base is irrelevant for this argument because there is no option for push notifications with a browser on iOS, even with Apple’s propriety push implementation for Safari. Apple’s Safari push system is only for Mac OS X (desktop) versions of Safari.

So even if XenForo supported Apple’s Safari push, literally the only operating system and browser that could use it is users who use Safari on OS X. Again... it still wouldn’t work on iOS/iPhone/iPad.
 
Neither. I'm currently struggling to find the value in foldable phones for my use.

Either way, not a fan of Samsung products at all so almost certainly not a Galaxy of any kind. Definitely leaning towards Huawei, so likely a Huawei Mate 20 Pro or whatever the equivalent will be at the time.
 
Neither. I'm currently struggling to find the value in foldable phones for my use.

I definitely don't understand it, the Samsung one looks like a joke, the Huawei one looks like it would actually be usable by comparison though.

Definitely leaning towards Huawei, so likely a Huawei Mate 20 Pro or whatever the equivalent will be at the time.

I've never really been a fan of Huawei phones, everyone I've seen has just felt cheap. Have you considered the Pixel? That's probably what I'd go with if I wanted to use an Android phone
 
Except iOS install base is irrelevant for this argument because there is no option for push notifications with a browser on iOS, even with Apple’s propriety push implementation for Safari. Apple’s Safari push system is only for Mac OS X (desktop) versions of Safari.

So even if XenForo supported Apple’s Safari push, literally the only operating system and browser that could use it is users who use Safari on OS X. Again... it still wouldn’t work on iOS/iPhone/iPad.
Personally I chuckle over iOS users forking over their cash for basic functionality that's free for everyone else. Great business plan though, make 'em think it's some great innovation nobody else can get. Cult-like.
 
Personally I chuckle over iOS users forking over their cash for basic functionality that's free for everyone else. Great business plan though, make 'em think it's some great innovation nobody else can get. Cult-like.
Depends if you are after “basic functionality” or not. Personally I see a lot of upside and downside to both iOS and Android. But one thing I’ve noticed when using both is that Apple’s CPUs are beasts. The same stuff feels a lot faster on iPhones to me. Probably just a benefit of one company controlling the hardware and the CPU being built exactly for that hardware and operating system.

To me, it feels like Apple’s Axx series CPUs are about 2 years ahead of Snapdragon CPUs that most Android devices use.

That being said, Apple needs to get the standards Push API rolling in iOS sooner rather than later please. 😀

 
Except iOS install base is irrelevant for this argument because there is no option for push notifications with a browser on iOS, even with Apple’s propriety push implementation for Safari. Apple’s Safari push system is only for Mac OS X (desktop) versions of Safari.

So even if XenForo supported Apple’s Safari push, literally the only operating system and browser that could use it is users who use Safari on OS X. Again... it still wouldn’t work on iOS/iPhone/iPad.

So then work with what Apple has requested and push out a tool to create a native App for Xenforo websites. There is a way, it’s just ALOT more work, agreed. In my opinion however that work is where the reward is.
 
It’s probably a mix of things ranging from conspiracy theories to resources required.
  • Not supporting web push on iOS means more people will create iOS apps just for push functionality.
  • All browsers on iOS are really wrappers for WebKit... meaning Chrome or any other browser for iOS can’t support push API either. So browser competition isn’t a thing for them.
  • Not a high priority because if you are an iPhone user, the lack of web push isn’t going to be enough to make you switch to Android.
  • This is probably the biggest issue... Service Workers are required for Push API, which means your iOS device will need to have a constantly running process which will not be good for your phone’s battery life. Probably what we’ll see when it finally becomes available is some sort of hybrid system where the Service Workers aren’t actually running all the time, and instead get an invisible push notification via the normal push system to wake them up and do their thing when needed. So for Apple it will be more work to do it more efficiently than normal which would just sacrifice overall battery life for web push.
Service Workers are. New addition to Safari, so at least they are slowly moving in the right direction.
One thing I think you missed in this post is the fact that iOS offers a one-stop shop to manage notifications.

The Settings > Notifications UI would need to be updated to support ServiceWorker-based notifications with opt-out functionality.

Not saying it’s impossible, and I have no idea how it works on Android (or if you have to go to the website to opt out), just saying that there’s technical reasons why they haven’t implemented it yet.

Apple are never first, but they are “best” - they never implement features just to say they have them (see: NFC when Android snobs lorded it over iPhone, even though it had extremely limited practical use until contactless payments became prevalent). Therefore it would stand to reason that they won’t implement SW Push until they have a way of managing notification settings the same way you can notifications for native apps.

I personally have no problem with this approach.
 
I know iOS users would fork over the cash to make it worth a website’s time/effort to make it happen......
There are things like Tapatalk and Pushover now so that's not true. Much less so because there are so many free places to congregate and discuss topics these days at zero charge. And again, because OneSignal ruined web push for the masses.
 
Top Bottom