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

can't change the message title

sfsfco opened this issue · comments

thanks, Louis for your great effort I did some tweak to split the client area and save the subscription in the database, but still couldn't find out how the change the notification title dynamically
her is my code in the (send_push_notification.php)
`foreach ($notifications as $notification) {

$webPush->sendNotification(
    $notification['subscription'],
    $notification['payload'],
    false,
    array('topic'=>'my topic')
);

}
$webPush->flush();
and this is how i try to get the title in (serviceWorker.js)return self.registration.showNotification(event.data.topic, {
body: body,
icon: 'https://vignette.wikia.nocookie.net/plantsvszombies/images/9/9c/Pvz2_icon.png/revision/latest?cb=20140621162342',
vibrate: [200, 100, 200, 100, 200, 100, 200],
tag: 'vibration-sample'
});`

Done I sent the title in the payload as a JSON format