<script>
const messaging = firebase.messaging();
messaging
.requestPermission()
.then(function () {
console.log("Notification permission granted.");
// get the token in the form of promise
return messaging.getToken()
})
.then(function(token) {
console.log(token);
})
.catch(function (err) {
console.log("Unable to get permission to notify.", err);
});
</script>
Vreau sa verific daca “token” este identic cu valoarea oferita de {$user->_fcm}
Am incercat ceva de genul
const messaging = firebase.messaging();
messaging
.requestPermission()
.then(function () {
console.log("Notification permission granted.");
// get the token in the form of promise
return messaging.getToken()
})
.then(function(token) {
console.log(token);
if((token)=={$user->_fcm})
{
console.log("ok");
}
else
{
saveToken(token);
}
})
.catch(function (err) {
console.log("Unable to get permission to notify.", err);
});
imi da eroarea Uncaught SyntaxError: Unexpected token ‘:’ in consola.
Ma poate ajuta cineva ?