下面是我用来发送本地推送的代码。
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = pickerDate;
NSString *alertText = [NSString stringWithFormat:@"Test Push Title"];
localNotification.alertBody = alertText;
localNotification.soundName = @"Glass.caf";
localNotification.alertAction = @"Show me the item";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
// Request to reload table view data
[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadData" object:self];
但是现在我想以小时为间隔发送从日期到现在的推送。
例如,我想从 2014 年 1 月 1 日到 2014 年 2 月 2 日发送推送。
现在每天我都会推 3 次。每次推送将在晚上 8 点开始,在 6 点后的第二天我会得到休息推送。表示早上 8 点第一次推送,下午 2 点第二次推送,晚上 8 点第三次推送。
知道怎么做吗?
任何指导将不胜感激。
实际上,我想提醒我将在哪里输入以下内容。
Daily how many times you will have medicine
From what time you will have medicine
After how many interval you will have another medicine
For how long days you will have medicine
编辑 1
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = pickerDate;
NSTimeInterval interval = 1*60;
for (int i =0;i<=2;i++ ) {
// setup the notification using the fire date
// pickerDate = [pickerDate dateByAddingTimeInterval:interval];
pickerDate = [pickerDate dateByAddingTimeInterval:interval];
}
我尝试使用此代码,但我仍然得到一推。我期待4次推...