Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

onMessage payload not working #202

Open
blpraveen opened this issue Sep 29, 2020 · 1 comment
Open

onMessage payload not working #202

blpraveen opened this issue Sep 29, 2020 · 1 comment

Comments

@blpraveen
Copy link

blpraveen commented Sep 29, 2020

Hi,
I am trying to integrate FCM in my payment page. it shows numberTokensSuccess 1 but no payload. I am writing the output or payload to console.It is not working. Please help

I have added to top of the page

<script src="https://www.gstatic.com/firebasejs/7.21.1/firebase-app.js"></script>
   <script src="https://www.gstatic.com/firebasejs/7.21.1/firebase-messaging.js"></script>
<link rel="manifest" href="{{ asset('core/manifest.json') }}" />

my firebase file.php <script src="{{ asset('assets/js/firebase.js') }}"></script>

const firebaseConfig = {
  apiKey: "XXX",
  authDomain: "XXX",
  databaseURL: "XXX",
  projectId: "XXX",
  storageBucket: "XXX",
  messagingSenderId: "XXX",
  appId: "XXX",
  measurementId: "XXX"
};
  firebase.initializeApp(firebaseConfig);
  
  const messaging = firebase.messaging();
		messaging.requestPermission()
		.then(function() {
			console.log("Notification permission granted");
			return messaging.getToken();
		}).then(function(token) {
			$('#device_token').val(token);
			console.log(token);
		}).catch(function (err){
			console.log("Unable to get the permission to notify",err);
		});
		messaging.onMessage((payload) => {
			console.log(payload);
		});
@AhmedBenCheikh
Copy link

hi,
also the data object not existing !!!!???
i can't get the badge count from notification!!!!!

Screen Shot 2020-10-17 at 11 44 04 AM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants