Firebase Messaging with Django

Asked

Viewed 41 times

1

I am a long time already getting caught up with it. After hours and days I could see a light at the end of the tunnel.

I’m using a plugin for Django, this one: https://github.com/xtrinch/fcm-django

In my INDEX.HTML I have the following code:

<script src="https://www.gstatic.com/firebasejs/4.4.0/firebase.js"></script>
<script>
// Initialize Firebase
  var config = {
    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 don’t know where I’m going wrong, I ran the documentation, followed every tutorial I saw on the Google results. The user’s TOKEN comes up, I send a message and appears in my devtools only one message:

Service Worker was updated because "Update on reload" was checked in the DevTools Application panel.

Every time I send a push it appears, but push it at all. I added a device in this plugin I’m using but has a field that I don’t understand.

The field Registration Token i added the user generated token. There is another field called Device ID (Unique device Identifier). I left it blank because I don’t know how to capture it.

Somebody give me a hand please? I would have to make it work with Django, not a Nodejs no.

Thanks in advance.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.