Minishlink / web-push-php-example

An example for sending Web Push notifications, using web-push-php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

image and link in message and title is not working

way2enjoy2 opened this issue · comments

i tried to add link and images to my notification but its not working. i have seen one thread and changed to json format but then also its showing raw html.

i tried several things to change the title but its not working and tried to add image like this its not working either.

it will be great if u add image, link and title option is example. here is my code

self.addEventListener('push', function (event) {
if (!(self.Notification && self.Notification.permission === 'granted')) {
return;
}

const sendNotification = body => {
    // you could refresh a notification badge here with postMessage API
  const title = "test Request";
    const options = {
     icon: "/icon.png"
          };
    return self.registration.showNotification(title, options, {
        body,
    });
};

if (event.data) {

  const message = event.data.json();
    event.waitUntil(sendNotification(message));
}

});

in php i send like this

$webPush = new WebPush($auth);

$res = $webPush->sendNotification(
$subscription2,
"You have a new message!\n$chatlink ",
true
);

Please ask this on StackOverflow or other more appropriate forum