Skip to content

Commit

Permalink
Change example with json
Browse files Browse the repository at this point in the history
  • Loading branch information
Minishlink committed Oct 17, 2023
1 parent a7c511b commit b9aa928
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/send_push_notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

$report = $webPush->sendOneNotification(
$subscription,
"Hello! 👋"
'{"message":"Hello! 👋"}',
);

// handle eventual errors here, and remove the subscription from your server if it is expired
Expand Down
4 changes: 2 additions & 2 deletions src/serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ self.addEventListener('push', function (event) {
};

if (event.data) {
const message = event.data.text();
event.waitUntil(sendNotification(message));
const payload = event.data.json();
event.waitUntil(sendNotification(payload.message));
}
});

0 comments on commit b9aa928

Please sign in to comment.