android 连续发送,本地通知在Android设备中持续触发一分钟

我正在使用插件在ionic 2应用程序中处理本地通知-

ionic cordova plugin add cordova-plugin-local-notification

npm install @ionic-native/local-notifications

该通知在ios设备中运行得非常好,但是对于android来说却显示出意外的行为。

异常行为- 在设定的时间重复同一天的通知。

当前行为 -通知持续一分钟。

我的要求是在每周的特定日期重复由用户设置的本地通知,该通知也应在用户设置的同一天和同一时间重复。

这是我的代码段-

makeLocalNotificationOn(mainDayNotifyObj, index) {

let currentDate = new Date();

let currentDay = currentDate.getDay(); // Sunday = 0, Monday = 1, etc.

let indexOfDay;

for (let i = 0; i < this.remainderDaysArray.length; i++) {

if (mainDayNotifyObj.dayName == this.remainderDaysArray[i]) {

indexOfDay = i;

break;

}

}

let setTime = mainDayNotifyObj.time.split(":");

let hours = parseInt(setTime[0]);

let minutes = parseInt(setTime[1]);

let firstNotificationTime = new Date();

let dayDifference = indexOfDay - currentDay;

if (dayDifference < 0) {

dayDifference = dayDifference + 7; // for cases where the day is in the following week

}

firstNotificationTime.setHours(firstNotificationTime.getHours() + (24 * (dayDifference)));

firstNotificationTime.setHours(hours);

firstNotificationTime.setMinutes(minutes);

let weekDay = firstNotificationTime.getDay();

let remainderObj = {

id: index,

title: 'Hello',

text: 'Its time',

foreground: true,

trigger: {every: {weekday: weekDay, hour: hours, minute: minutes},firstAt: firstNotificationTime}

};

this.notificationArray.push(remainderObj);

this.platform.ready().then(() => {

this.localNotifications.schedule(this.notificationArray);

});

}

任何帮助将不胜感激。谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值