Я сделал один пример приложения, которое запускает локальное уведомление.
Когда срабатывает уведомление, оно всегда показывает баннер в области уведомлений на устройстве, который я показал на изображении.
Но мне нужно оповещение, а не это, и я хочу выполнить действие на основе выбранного параметра из этого оповещения.
Код для запуска локального уведомления приведен ниже.
-(IBAction)setNotification:(id)sender{
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
{
return;
}
localNotif.timeZone = [NSTimeZone defaultTimeZone];
// Get the year, month, day from the date
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit|NSTimeZoneCalendarUnit|NSSecondCalendarUnit|NSHourCalendarUnit|NSMinuteCalendarUnit fromDate:[NSDate date]];
// Set the second to be zero
components.minute = components.minute + 1;
components.second = 0;
// Create the date
NSDate *date = [[NSCalendar currentCalendar] dateFromComponents:components];
NSLog(@"Fire Date :: %@",date);
localNotif.fireDate = date;
localNotif.alertBody = [NSString stringWithFormat:@"First Alarm"];
localNotif.alertAction =@"Ok";
localNotif.soundName=@"Alarm_1.mp3";
localNotif.applicationIconBadgeNumber = 1;
localNotif.alertAction = @"Application name";
localNotif.HasAction = true;
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}
Может ли любое тело, пожалуйста, скажите мне, есть ли какая-либо ошибка.
Заранее спасибо.