我使用nativescript-local-notifications和nativescript-plugin-firebase。Nativescript。 nativescript-local-notifications總是創建兩個通知
我想在服務器向我發送消息時每次創建通知。這裏是代碼:
firebase.init({
storageBucket: 'gs://shao-by-partner-firebase.appspot.com',
persist: true, // optional, default false
onPushTokenReceivedCallback: function (token) {
Config.device_token = token;
console.log("Firebase plugin received a push token: " + token);
},
onMessageReceivedCallback: function (message) {
LocalNotifications.schedule([{
id: 1,
title: 'The title',
body: 'Recurs every minute until cancelled',
ticker: 'The ticker',
badge: 1,
smallIcon: 'res://heart.png'
}]).then(
function() {
console.log("Notification scheduled");
},
function(error) {
console.log("scheduling error: " + error);
}
)
}
}).then(
function (result) {
console.log("Firebase is ready");
},
function (error) {
console.log("firebase.init error: " + error);
}
);
}
但始終創建一個的兩個通知代替。並且第一個通知是空的。第二個通知是我創建的。怎麼了?
可能你是對的,但是當我刪除LocalNotifications.schedule(...)時,兩個通知都不會創建。 –
是的,你是完全正確的,很抱歉這麼長的答案 –