每分钟更新文本Cordova插件本地通知



我尝试每分钟使用电话scheduleMinutely = function () { var sound = device.platform == 'Android' ? 'file://ting.wav' : 'file://beep.caf'; cordova.plugins.notification.local.schedule({ id: localStorage.text, title: 'Note', text: localStorage.text, every: 'minute', sound: sound, icon: 'res://icon', smallIcon: 'res://ic_popup_sync' }); };

中的Cordova-plugin-local-notifications更新文本
localStorage.text = 0;
document.addEventListener('deviceready', function () {
   cordova.plugins.notification.local.on('schedule', function (notification) {
      console.log('onschedule', arguments);
      localStorage.text ++;
   });
});

第一次显示0,但是1分钟后的第二次显示0,而不是1,我认为它不返回时间表。

谢谢您的帮助!

重点是,您无法在通知中使用动态文本。

如果要使用不同的文本,则必须为每个文本创建一个单独的通知。在这种情况下,使用推送通知也许更好。

但是请注意,每个平台上都有您可以放置多少个通知的局限性。

最新更新