Jump to content

Community

Why not offer push notifications solution


Recommended Posts

2 hours ago, tonyv said:

Engagement without substance is at best overrated, more accurately useless. I want substance, not clicks. I don't need their noses in an app if they're only gonna click LIKE and not write anything. 

It’s an assumption that increasing engagement decreases substance. I disagree with that assumption for my own community, but I suppose that is very dependent on each community and the type of content you have to begin with. 

Link to post
Share on other sites
  • 2 months later...
  • Replies 80
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

I say leave Apple and it's iPhones in the dust. Why must everybody wait for some company which may end up NEVER doing that? I sincerely believe that you should go with Android which has a HUGE userbas

+1000.  I have a community for enthusiasts of a specific sport.  My community competes for participation and attention against a Facebook group for the same sport.  The Facebook group is crushing my c

It’s instant and on the system level. You don’t need to open the site manually or check your emails. You get a notification on your mobile device. Whatever you do, wherever you are. It’s how the big p

Posted Images

  • 1 year later...
On 5/16/2019 at 6:53 AM, Matt said:

Sales figures mean nothing sadly. There's little point investing a lot of energy into a system that does not work on one of the top two phone platforms.

I think we're on Web 5.0 by now.

I would agree, other than push notifications which require an app for iOS.

Take a look at https://firebase.google.com/ its provide a full solution for native/apps/web in one place, and the best Cloud Messaging (FCM) is no-cost and it can be handled by php with a simple http 1.1 API:

<?php

$request = new HttpRequest();
$request->setUrl('https://fcm.googleapis.com/fcm/send');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
    'content-type' => 'application/json',
  'authorization' => 'key=<CONFIG_SERVER_KEY>'
));

$body = [
    "to" => "<user-firebase-token>",
    "time_to_live" => 259200,
    "data" => [ //Some custom stuff
    	"update"=> true, //you can tell the service worker to self update
    	"actions"=> [["action"=> "ok", "title"=> "OK"],["action"=>"link", "title"=>"Acces","link"=>"https://forum.com"]],  //Send somo actions to compose buttons
    	"actionsUrl"=> {"link"=>"https://google.com"}, //and ask to open another url
    ],
     "notification": [
           "body" => "Fancy Notification",
           "title" =>"Small Tittle",
           "image"=> "https://cdn.forum.com/monthly_2020_09/log.png.c10d6f024b155b08ab5f46d029749b42.png", //think on send topic first image
           "click_action"=> "https://invisioncommunity.com/forums/topic/451842-why-not-offer-push-notifications-solution/" //
       ],
      "fcm_options"=> [
       	 "analytics_label"=> "forum-push"
       ]
   ];
$request->setBody(json_encode($body));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

At front-end with service worker (supported by all modern browsers) 

// If you would like to customize notifications that are received in the
// background (Web app is closed or not in browser focus) then you should
// implement this optional method.
messaging.onBackgroundMessage(function(payload) {
  console.log('[firebase-messaging-sw.js] Received background message ', payload);
     // Customize notification here
      const {notification} = payload;
      const {data} = payload;
      data.click_action = notification.click_action;	  
	  const {title} = notification;
	  const notificationOptions = {
		  requireInteraction: true, //Some default options
		  data: data,
		  ...notification
		  };
	
	  console.log(notificationOptions);
	  //Show notification
	  return self.registration.showNotification(title,
		notificationOptions);
});

 

More details: https://github.com/firebase/quickstart-js/tree/master/messaging


All you need to do is handle the token from firebase to user, and then in the service queue send notifications to user when needed.

When the user has the focus on the web page you can handle the notifications in the UI.

 

It will work on all top users and technologies.

 

 

 

Edited by Marquinhos
Link to post
Share on other sites
2 hours ago, Marquinhos said:

Take a look at https://firebase.google.com/ its provide a full solution for native/apps/web in one place, and the best Cloud Messaging (FCM) is no-cost and it can be handled by php with a simple http 1.1 API:


<?php

$request = new HttpRequest();
$request->setUrl('https://fcm.googleapis.com/fcm/send');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
    'content-type' => 'application/json',
  'authorization' => 'key=<CONFIG_SERVER_KEY>'
));

$body = [
    "to" => "<user-firebase-token>",
    "time_to_live" => 259200,
    "data" => [ //Some custom stuff
    	"update"=> true, //you can tell the service worker to self update
    	"actions"=> [["action"=> "ok", "title"=> "OK"],["action"=>"link", "title"=>"Acces","link"=>"https://forum.com"]],  //Send somo actions to compose buttons
    	"actionsUrl"=> {"link"=>"https://google.com"}, //and ask to open another url
    ],
     "notification": [
           "body" => "Fancy Notification",
           "title" =>"Small Tittle",
           "image"=> "https://cdn.forum.com/monthly_2020_09/log.png.c10d6f024b155b08ab5f46d029749b42.png", //think on send topic first image
           "click_action"=> "https://invisioncommunity.com/forums/topic/451842-why-not-offer-push-notifications-solution/" //
       ],
      "fcm_options"=> [
       	 "analytics_label"=> "forum-push"
       ]
   ];
$request->setBody(json_encode($body));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

At front-end with service worker (supported by all modern browsers) 


// If you would like to customize notifications that are received in the
// background (Web app is closed or not in browser focus) then you should
// implement this optional method.
messaging.onBackgroundMessage(function(payload) {
  console.log('[firebase-messaging-sw.js] Received background message ', payload);
     // Customize notification here
      const {notification} = payload;
      const {data} = payload;
      data.click_action = notification.click_action;	  
	  const {title} = notification;
	  const notificationOptions = {
		  requireInteraction: true, //Some default options
		  data: data,
		  ...notification
		  };
	
	  console.log(notificationOptions);
	  //Show notification
	  return self.registration.showNotification(title,
		notificationOptions);
});

 

More details: https://github.com/firebase/quickstart-js/tree/master/messaging


All you need to do is handle the token from firebase to user, and then in the service queue send notifications to user when needed.

When the user has the focus on the web page you can handle the notifications in the UI.

 

It will work on all top users and technologies.

 

 

 

The comment Matt made was in reference to push via web, which isn't supported in iOS without using native apps. They now have a native app.

Link to post
Share on other sites
  • Recently Browsing   0 members

    No registered users viewing this page.


×
×
  • Create New...

Important Information

We use technologies, such as cookies, to customise content and advertising, to provide social media features and to analyse traffic to the site. We also share information about your use of our site with our trusted social media, advertising and analytics partners. See more about cookies and our Privacy Policy