web-push-php
web-push-php copied to clipboard
Issue with Firefox androïd
Please confirm the following:
- [x] I have read the README entirely
- [x] I have verified in the issues that my problem hasn't already been resolved
Setup
Please provide the following details, the more info you can provide the better.
- Operating System: <Android>
- PHP Version: <7.4 >
- web-push-php Version: <6.0.3>
Please check that you have installed and enabled these PHP extensions :
- [x] gmp
- [x] mbstring
- [x] curl
- [x] openssl
Please select any browsers that you are experiencing problems with:
- [ ] Chrome
- [ ] Firefox
- [x] Firefox for Mobile
- [ ] Opera for Android
- [ ] Samsung Internet Browser
- [ ] Other
Problem
Hi, I use this library with Firefox desktop , Chrome desktop and Chrome androïd and all is right, it's work fine. But with Firefox androïd I get a subscription with value=null
Expected
I want to get subscription
Features Used
- [] VAPID Support
- [] Sending with Payload
Example / Reproduce Case
Here is the code I use
function checkNotificationPermission() { return new Promise((resolve, reject) => { if (Notification.permission === 'denied') {
return reject(new Error('Push messages are blocked.'));
}
if (Notification.permission === 'granted') {
// Here I get granted value it's ok //
return resolve();
}
if (Notification.permission === 'default') {
return Notification.requestPermission().then(result => {
if (result !== 'granted') {
reject(new Error('Bad permission result'));
} else {
resolve();
}
});
}
return reject(new Error('Unknown permission'));
});
} function push_subscribe() { changePushButtonState('computing');
return checkNotificationPermission()
.then(() => navigator.serviceWorker.ready)
.then(serviceWorkerRegistration =>
serviceWorkerRegistration.pushManager.subscribe(
{
userVisibleOnly: true,
applicationServerKey: urlBase64ToUint8Array(applicationServerKey)
})
)
.then(subscription => {
/// here I get subscription =null console.log("subscription", subscription); ///
// Subscription was successful
// create subscription on your server
return push_sendSubscriptionToServer(subscription, 'POST');
})
.then(subscription => subscription && changePushButtonState('enabled')) // update your UI
.catch(e => {
if (Notification.permission === 'denied') {
// The user denied the notification permission which
// means we failed to subscribe and the user will need
// to manually change the notification permission to
// subscribe to push messages
console.warn('Notifications are denied by the user.');
changePushButtonState('incompatible');
} else {
// A problem occurred with the subscription; common reasons
// include network errors or the user skipped the permission
console.error('Impossible to subscribe to push notifications', e);
changePushButtonState('disabled');
}
});
}
Other
This is a Javascript issue with the browser (if it is). Not a PHP issue. This repository contains only the php-script to allow notifications over your webserver.
Your error has to do with the browser or with the W3C-API*. Not with this library.
What is applicationServerKey?
Hi,
thanks for this answer
I'm not sure I really understand what you mean by "What is |applicationServerKey|?" but if you mean the value it's 'BER7JSVXnZY2jDWAmuK9OT719QNjRzwE2XCKSp74stJxbTmueVKGUeOPrgiOuTTZs-rDCJBEjVpkozhsBXXNH4M';
I saw that Firefox Android needs bridge with Google Cloud Messaging, maybe it's the reason of the issue.
Best regards
Cordialement. Patrice Coacolo
l' @rrêt du NET https://arret-net.fr
1 rue du Repos 38450 Vif
06 19 96 36 86 Le 30/11/2020 à 12:05, Adriano a écrit :
This is a Javascript issue with the browser (if it is). Not a PHP issue. This repository contains only the php-script to allow notifications over your webserver.
Your error has to do with the browser or with the W3C-API*. Not with this library.
What is |applicationServerKey|?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/web-push-libs/web-push-php/issues/308#issuecomment-735717681, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH6FMUJELH5BRHDPZBTGFNDSSN367ANCNFSM4UGSUOCQ.
Before you can use the push notification, you have to setup the webpage and browser.
Your subscription is null, before you are using this library or any push notification functionality.
You can check my webpage (test script) if you want to test your browser for notifications: https://projects.petrucci.ch/webpush/
And no, you don't need Google Cloud Messaging, if you have your own php-server.
You have to: 1- enable "normal" notifications (browser) 2- register a service worker (javascript) 3- register push notification (javascript-browser) 4- send push notification from your server 5- get data from the browser
Your error occurs in step 3. This library is for step 4, so it can't be the cause.
thanks,
step 1 one and step 2 are ok and it works well on Firefox Desktop, Chrome Desktop and Chrome Android( mobile)
I get the notifications with this three "browser" all is right.
The issue is only with Firefox android.
Thanks for the url, I'll try with it
Cordialement. Patrice Coacolo
l' @rrêt du NET https://arret-net.fr
1 rue du Repos 38450 Vif
06 19 96 36 86 Le 30/11/2020 à 13:25, Adriano a écrit :
Before you can use the push notification, you have to setup the webpage and browser.
Your subscription is null, before you are using this library or any push notification functionality.
You can check my webpage (test script) if you want to test your browser for notifications: https://projects.petrucci.ch/webpush/ https://projects.petrucci.ch/webpush/
And no, you don't need Google Cloud Messaging, if you have your own php-server.
You have to: 1- enable "normal" notifications (browser) 2- register a service worker (javascript) 3- register push notification (javascript-browser) 4- send push notification from your server 5- get data from the browser
Your error occurs in step 3. This library is for step 4, so it can't be the cause.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/web-push-libs/web-push-php/issues/308#issuecomment-735755627, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH6FMUPZ3G6OD2CZMFTI7I3SSOFMFANCNFSM4UGSUOCQ.
With your url https://projects.petrucci.ch/webpush/ https://projects.petrucci.ch/webpush/ I get the same error on Firefox android : "Subscription null"
I've my answer, the browser is the issue
It's Firefox Daylight version 83.1.0
Cordialement. Patrice Coacolo
l' @rrêt du NET https://arret-net.fr
1 rue du Repos 38450 Vif
06 19 96 36 86 Le 30/11/2020 à 13:25, Adriano a écrit :
Before you can use the push notification, you have to setup the webpage and browser.
Your subscription is null, before you are using this library or any push notification functionality.
You can check my webpage (test script) if you want to test your browser for notifications: https://projects.petrucci.ch/webpush/ https://projects.petrucci.ch/webpush/
And no, you don't need Google Cloud Messaging, if you have your own php-server.
You have to: 1- enable "normal" notifications (browser) 2- register a service worker (javascript) 3- register push notification (javascript-browser) 4- send push notification from your server 5- get data from the browser
Your error occurs in step 3. This library is for step 4, so it can't be the cause.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/web-push-libs/web-push-php/issues/308#issuecomment-735755627, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH6FMUPZ3G6OD2CZMFTI7I3SSOFMFANCNFSM4UGSUOCQ.
Hello @arretnet are you aware if it's possible that when one clicks on a notification if it's possible that it can open up the browser and go to a specific website and or section on that website?