Как удалить уведомление, которое было отображено (присутствовать на телефонной панели), но не повторить попытку пользователя? используя cordova https://github.com/katzer/cordova-plugin-local-notifications/Как удалить отображаемое уведомление с помощью cordova
Я проверяю другой способ, но не получил никаких свойств или функций. хотя при регистрации
window.plugin.notification.local.add({
id: String, // A unique id of the notification
date: Date, // This expects a date object
message: String, // The message that is displayed
title: String, // The title of the message
repeat: String, // Either 'secondly', 'minutely', 'hourly', 'daily', 'weekly', 'monthly' or 'yearly'
badge: Number, // Displays number badge to notification
sound: String, // A sound to be played
json: String, // Data to be passed through the notification
autoCancel: Boolean, // Setting this flag and the notification is automatically cancelled when the user clicks it
ongoing: Boolean, // Prevent clearing of notification (Android only)
}, callback, scope);
у вас есть возможность
autoCancel: Boolean, // Setting this flag and the notification is automatically cancelled when the user clicks it
Это работает, но как я могу удаляется с помощью кодирования.
Я попытался отменить По идентификатору
function cancelLocalNotificationById(id){
window.plugin.notification.local.cancel(id, function(){
alert("cancel callback", id);
});
}
}
будет регистрироваться в onTrigger. и отменить по идентификатору будет работать через 5 секунд
function onTrigger(){
window.plugin.notification.local.ontrigger = function (id, state, json) {
alert("onTrigger fired");
alert(id);
// Cancel alert after 5 seconds...
timeouts.push(setTimeout(function(){
cancelLocalNotificationById(id);
alert(id);
//alert("cancel reslut"+cancel.status);
},5000));
}
Я сделал это, но уведомление все еще существует –
при нажатии удаления уведомления, но отменить по id не –
@MohammadFaizanKhan: можете ли вы показать пример идентификатора, который используете? –