-1

通知應在選定的日期和時間觸發。

如何使用window.plugin.notification.local.add或ontrigger與稍後將插入的日期(動態)

該通知也可以在後臺運行,但我只能聽到聲音,並且通知沒有出現在頂部。
我已經嘗試過「觸發器」的方法,但它沒有奏效。我該怎麼辦?
請幫幫我。

.... 
 
var reminderTime = new Date(DateFromTheDataBase[index]); 
 

 
opt = { 
 
    id   : indexID, 
 
    title  : 'Title', 
 
    message : data.intent+'\n', 
 
    sound  : '/www/mySound/sound.wav', 
 
    autoCancel : true, 
 
    date \t \t : reminderTime 
 
} 
 
\t \t \t if(window.plugin && window.plugin.notification.local){ 
 
\t \t \t \t //window.plugin.notification.local.cancelAll(); 
 
\t \t \t \t window.plugin.notification.local.add(opt); 
 
}

回答

0

這就是我已經解決了這個問題。
也許它可以幫助別人。

我曾與這個插件: 「de.appplant.cordova.plugin.local通知」 的數據基礎日期沒有工作或觸發

window.plugin.notification.local.add({ 
 
    id:  1, 
 
    message: 'wow', 
 
    date: DateFromDataBase 
 
});



這就是我在方法onDeviceready()中使用window.setInterval()的原因。

function vTime(){ 
 

 
if(CurrentHourID==IDfromDB){ 
 
\t \t \t \t navigator.notification.alert(storedData.intent, // message 
 
    \t \t \t null, // callback 
 
    \t \t \t null, // title 
 
    \t \t \t 'Ok'  // buttonName 
 
\t \t \t \t ); \t \t \t \t 
 
\t \t \t //LocalNotification 
 
var backgroundID = 1; 
 
var options = { 
 
    id   : backgroundID, 
 
    title  : 'wow', 
 
    message : storedData.intent, 
 
    //sound  : '/www/sounds/lollipop.wav', 
 
autoCancel : true 
 
} 
 
if(window.plugin && window.plugin.notification.local){ 
 
\t window.plugin.notification.local.add(options); 
 
}else{ 
 
\t \t alert('**** not ready or no internet connection.'); 
 
} 
 
\t \t \t \t navigator.notification.vibrate(2000); 
 
\t \t \t \t navigator.notification.beep(1); 
 
\t \t \t }} 
 
\t \t var currentTime=window.setInterval(function() { 
 
\t \t vTime()}, 1000);