I've been struggling for a long time. After hours and days I could see a light at the end of the tunnel.
I'm using a plugin for Django, this one: link
In my INDEX.HTML I have the following code:
<script src="https://www.gstatic.com/firebasejs/4.4.0/firebase.js"></script><script>//InitializeFirebasevarconfig={apiKey:"XXXXXX",
authDomain: "XXXXXX",
databaseURL: "XXXXX",
projectId: "XXXXXX",
storageBucket: "XXXXX",
messagingSenderId: "XXXXXXX"
};
var app = firebase.initializeApp(config);
var messaging = firebase.messaging(app);
messaging.requestPermission()
.then(function() {
console.log('Notification permission granted.');
return messaging.getToken();
})
.then(function(token) {
console.log(token); // Display user token
})
.catch(function(err) { // Happen if user deney permission
console.log('Unable to get permission to notify.', err);
});
messaging.onMessage(function(payload){
console.log('onMessage',payload);
})
</script>
I do not know where I'm going wrong, I've gone through the documentation, followed all the tutorials I've seen in Google results. It arrives to appear the TOKEN of the user, I arrive to send a message and appears in my devtools only a message:
Service Worker was updated because "Update on reload" was checked in the DevTools Application panel.
Every time I send a push this appears, but push does nothing at all. I added a device to this plugin that I'm using but it has a field I did not understand.
The Registration Token field I added the user generated token. There is another field called Device ID (Unique device identifier) . I left it blank because I do not know how to capture it.
Someone help me please? I would have to make Django work, do not roll a NodeJS no.
Thank you in advance.