Implemented PUSH notifications for XenForo

Alpha1

Well-known member
The responsive design already makes XenForo great on mobile devices. We almost do not need an app. But one thing is missing: Instant PUSH notifications.

If XenForo would have PUSH notifications then users could be notified of new alerts , events on their mobile device, in their browser, etc. This keeps users up to date and pulls off site users back onto the website.

Possibly with the addition of mini-apps.
 
Last edited:
Upvote 177
This suggestion has been implemented. Votes are no longer accepted.
It's not that easy as you need an apple Mac to generate the p12.

The Google one is easy just need a dev account.

This is very easy to do with onesignal. It just doesn't work on iPhone.
 
It is easy to code,
Code:
function notifyMe(username, text, theIcon) {
            var options = {
          body: text,
          icon: theIcon
      }
      // Проверка поддерживаемости браузером уведомлений
      if (!("Notification" in window)) {
        console.log("This browser does not support desktop notification");
      }
    
      // Проверка разрешения на отправку уведомлений
      else if (Notification.permission === "granted") {
        // Если разрешено то создаем уведомлений
        var notification = new Notification(username, options);
      }
    
      // В противном случает мы запрашиваем разрешение
      else if (Notification.permission !== 'denied') {
        Notification.requestPermission(function (permission) {
          // Если пользователь разрешил, то создаем уведомление
          if (permission === "granted") {
            var notification = new Notification(username, options);
          }
        });
      }
    
      // В конечном счете если пользователь отказался от получения
      // уведомлений, то стоит уважать его выбор и не беспокоить его
      // по этому поводу .
    }
        
        !function($, window, document, _undefined) {
            
        XenForo.initNotify = function($link) {
            var callback = function(ajaxData, textStatus) {
                if (ajaxData.error) {
                    console.log(ajaxData.error);
                }
                else
                {
                    if (ajaxData.body)
                    {
                        notifyMe(ajaxData.username, ajaxData.body, ajaxData.icon);
                    }
                }
            };
            
            $link.click(function(e) {
                e.preventDefault();
                if (("Notification" in window)) {
                    XenForo.ajax($link.attr('href'), {}, callback);
                }
                
            });       
        };
        XenForo.register('.initNotify', 'XenForo.initNotify');
    
    }(jQuery, this, document);
    var fn=function(){
        $('.initNotify').trigger('click');
    }
        
    if (document.location.href.indexOf('conversations') === -1)
    {
        setInterval(fn, 20000);
    }

Send request to server to get unread messages and create notification, good luck.
 
PUSH is not only great for Members. its also great for guests. PUSH allows you to send messages to people who have not registered.
There could even be a 'Watch' function for guests.
 
Had it for 7 months and nobody used it..

But the reason for that is probably because they had to register with pushbullet for it. Most people didn't even notice the option was there.
 
probably because they had to register with pushbullet for it.
Indeed. That doesnt work.
I use OneSignal and 2.5 thousand signed up so far and its growing every day. Its a one click signup. They only have to agree to the prompt to receive PUSH notification. Thats all.

The problem for guests is though that they do not receive interesting notifications. So they unsubscribe again. Which slows the growth rate down.

You can find OneSignal here.
 
Screen Shot 2017-08-26 at 12.32.26 AM.webp

I can only get Onesignal to work for
Android Phones Using default browser
Desktop/Laptop using chrome, firefox and safari
iOS version of Safari does not work
 
Top Bottom