EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 444 forks source link

When app closed in adnroid push notfication works but dialogs.alert shows empty message #336

Open rkhayyat opened 7 years ago

rkhayyat commented 7 years ago

Hi everyone, I'm using code presented by Jen looper to recieve FCM messaging. in android I recieve the push notification when the appication is closed but when I open the application I recieve an empty dialogs.alert. any help would be appreciated

here is a snapshut of the code, thanks in advanced:

setTimeout(function() { let firebase = require("nativescript-plugin-firebase"); firebase.init({ onPushTokenReceivedCallback: function(token) { console.log("Firebase push token: " + token); }, onMessageReceivedCallback: function(message) { dialogs.alert({ title: "Push message: " + (message.title !== undefined ? message.title : ""), message: JSON.stringify(message), okButtonText: "W00t!" }); }, //persist should be set to false as otherwise numbers aren't returned during livesync persist: false, //storageBucket: 'gs://yowwlr.appspot.com', onAuthStateChanged: (data: any) => { console.log(JSON.stringify(data)) if (data.loggedIn) { BackendService.token = data.user.uid; } else { BackendService.token = ""; } } }).then( function (instance) { console.log("firebase.init done"); }, function (error) { console.log("firebase.init error: " + error); } ); }, 3000);

EddyVerbruggen commented 7 years ago

If you want to process based on the title then you need to set that in the data payload of the notification you're sending.

rkhayyat commented 7 years ago

Thanks Eddy, another problem that I forgot to mention, each time I close the application and reopen it, a dialogue.alert popup with an empty msg even though no FCM notification was sent.

derFaizio commented 7 years ago

Dito. Having the same problem.

simba4everyoung commented 7 years ago

Having the same issue.