web-push-php
web-push-php copied to clipboard
Successfull message but nothing happens
Hello, I am using the web-push-php-example library, already generated the keys via linux, but for some reason when I press the button to Send notification, I don't receive notification at desktop (chrome) and phone (fireforx)... At console, I receive the return from send_push_notification file, which says:
"[v] Message sent successfully for subscription https://fcm.googleapis.com/fcm/send/e_Y1_jLWHoc:APA91bHb60sfgiIjtKJ2X9WiuXoQJqO4QZVVoSa47KQZ7ElgrAcOMLOz4qZGKKF2TO6z0Dt0e9nECT1GbPsX82Hdp74ottrsXjC6jONYFlzpRyTj1Se0kCuIX3FJlV6mP-NdV8oWNHKy."
I am testing at this URL: https://www.advogadosaqui.com.br/web-push-php-example/src/index/
I have tested at my android phone using chrome and there worked, but using my desktop (chrome too) It doesnt show nothing... Tried at firefox at my phone and didn't worked neither.
Someone could help me? ;(
after you've send your push your serviceWorker in your javascript should receive a push event where your eventlistener should trigger a notification here is the apple example of their serviceWorker :
// BrowserPetsWorker.js
self.addEventListener('push', (event) => {
let pushMessageJSON = event.data.json();
// Our server puts everything needed to show the notification
// in our JSON data.
event.waitUntil(self.registration.showNotification(pushMessageJSON.title, {
body: pushMessageJSON.body,
tag: pushMessageJSON.tag,
actions: [{
action: pushMessageJSON.actionURL,
title: pushMessageJSON.actionTitle,
}]
}));
}
you can check out their full tutorial here