- (void)scheduleNotification :(int) rowNo
{
[[UIApplication sharedApplication] cancelAllLocalNotifications];
Class cls = NSClassFromString(@"UILocalNotification");
if (cls != nil) {
UILocalNotification *notif = [[cls alloc] init];
notif.timeZone = [NSTimeZone defaultTimeZone];
NSString *descriptionBody=[[remedyArray objectAtIndex:rowNo]objectForKey:@"RemedyTxtDic"];
NSLog(@"%@",descriptionBody);
notif.alertBody = [NSString stringWithString:descriptionBody];
notif.alertAction = @"Show me";
notif.soundName = UILocalNotificationDefaultSoundName;
notif.applicationIconBadgeNumber = 1;
NSDictionary *userDict = [NSDictionary dictionaryWithObject:notif.alertBody
forKey:@"kRemindMeNotificationDataKey"];
notif.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
}
}
我有一个从 Sqldb 获取的列名频率,其中包含通知应出现在特定单元格的次数。如果频率 = 3 .. 通知应该在上午 8 点、下午 2 点然后 8 点触发 如果频率 = 4 .. 通知应该在上午 8 点、下午 12 点、下午 4 点然后晚上 8 点触发。
有没有办法做到这一点?如果有人可以帮助我,那就太好了