Я реализую локальное уведомление в своем приложении. На экране я разместил два текстовых поля со временем. Например, первое текстовое поле, имеющее 2,44 часа и второе текстовое поле, имеющее 2,45 вечера. Местное уведомление первого текстового поля не запускается в 2.44 часа. но уведомление о выпуске 2:45 вечера выполняется правильно. И, 2,44 часа показ уведомлений с 14:45.Два местных уведомления не сжигание
// viewcontroller.m file
Class cls = NSClassFromString(@"UILocalNotification");
if (cls != nil)
{
[[UIApplication sharedApplication] cancelAllLocalNotifications];
UILocalNotification *notif = [[cls alloc] init];
notif.fireDate = [datePicker date];
notif.timeZone = [NSTimeZone defaultTimeZone];
{
if ([MorningTimelbl.text length]>0)
{
notif.fireDate = [datePicker date];
notif.timeZone = [NSTimeZone defaultTimeZone];
notif.alertBody = @"It's time to take your eye drops";
notif.alertAction = @"Morning Notification";
notif.soundName = UILocalNotificationDefaultSoundName;
notif.applicationIconBadgeNumber = 1;
notif.repeatInterval = NSDayCalendarUnit;
NSDictionary *mornDict = [NSDictionary dictionaryWithObject:MorningTimelbl.text
forKey:kRemindMeNotificationDataKey];
notif.userInfo = mornDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
}
if ([LunchTimelbl.text length]>0)
{
notif.fireDate = [datePicker date];
notif.timeZone = [NSTimeZone defaultTimeZone];
notif.alertBody = @"It's time to take your eye drops";
notif.alertAction = @"Lunch Notification";
notif.soundName = UILocalNotificationDefaultSoundName;
notif.applicationIconBadgeNumber = 1;
notif.repeatInterval = NSDayCalendarUnit;
NSDictionary *lunchDict = [NSDictionary dictionaryWithObject:LunchTimelbl.text
forKey:kRemindMeNotificationDataKey];
notif.userInfo = lunchDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
}
}
//appdelegate.m
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Reminder"
message:notification.alertBody
delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
// Set icon badge number to zero
application.applicationIconBadgeNumber = 0;
}
, где я сделал ошибку? Спасибо заранее.
вы устанавливаете оба уведомления notif.fireDate такой же проблема. –
Спасибо за быстрый ответ. подождите, я проверю сейчас – Ramdhas
Спасибо за быстрый ответ. Я., его работа. спасибо много @DhavalBhadania – Ramdhas