我使用local-notafication插件 - https://github.com/katzer/cordova-plugin-local-notifications/blob/master/README.md#retrieve-the-ids-from-all-currently-scheduled-local-notifications
我正在安排通知,但这样可行,但我希望能够安排每隔一周只显示一次的通知,以及每隔三周只显示一次通知的通知,是否有人对如何安排通知我无法让这个工作?
var now = new Date().getTime(),
_60_seconds_from_now = new Date(now + 120*1000);
window.plugin.notification.local.add({
id: 28,
title: 'Reminder',
message: 'Dont forget to buy some flowers.',
repeat: 'weekly',
我希望能够每隔一周,每隔三周以及每周重播一次。
date: _60_seconds_from_now
});
这是在APPLocalNotification.m文件中
#ifdef NSCalendarUnitHour
[repeatDict setObject:
[NSNumber numberWithInt:NSCalendarUnitSecond] forKey:@"secondly"];
[repeatDict setObject:
[NSNumber numberWithInt:NSCalendarUnitMinute] forKey:@"minutely"];
[repeatDict setObject:
[NSNumber numberWithInt:NSCalendarUnitHour] forKey:@"hourly"];
[repeatDict setObject:
[NSNumber numberWithInt:NSCalendarUnitDay] forKey:@"daily"];
[repeatDict setObject:
[NSNumber numberWithInt:NSWeekCalendarUnit] forKey:@"weekly"];
[repeatDict setObject:
[NSNumber numberWithInt:NSCalendarUnitMonth] forKey:@"monthly"];
[repeatDict setObject:
[NSNumber numberWithInt:NSCalendarUnitYear] forKey:@"yearly"];
#else
[repeatDict setObject:
[NSNumber numberWithInt:NSSecondCalendarUnit] forKey:@"secondly"];
[repeatDict setObject:
[NSNumber numberWithInt:NSMinuteCalendarUnit] forKey:@"minutely"];
[repeatDict setObject:
[NSNumber numberWithInt:NSHourCalendarUnit] forKey:@"hourly"];
[repeatDict setObject:
[NSNumber numberWithInt:NSDayCalendarUnit] forKey:@"daily"];
[repeatDict setObject:
[NSNumber numberWithInt:NSWeekCalendarUnit] forKey:@"weekly"];
[repeatDict setObject:
[NSNumber numberWithInt:NSMonthCalendarUnit] forKey:@"monthly"];
[repeatDict setObject:
[NSNumber numberWithInt:NSYearCalendarUnit] forKey:@"yearly"];
#endif
[repeatDict setObject:
[NSNumber numberWithInt:NSEraCalendarUnit] forKey:@""];
return repeatDict;
}
是否可以添加新密钥?在那种情况下他们会怎么看?
答案 0 :(得分:0)
repeat: 'weekly'
意味着它会在每周都不断重演。所以它将在第一周重复,然后在第二周重复。使用您的代码第一次通知将在2分钟后给出。然后它将在下周的同一时间再次重复。然后在同一时间之后的一周内。等等......
这是你需要知道的吗?一个简短的建议:可能是你可以在该插件的问题页面上提出这个问题(如何添加该选项)。