다음 코드를 사용하여 특정 시간에 로컬 알림을 보냈습니다. 메서드에서 호출 할 때 잘 작동하지만 다른 메서드에서 호출 할 때 작동하지 않습니다.알림 fireTime이 작동하지 않습니다.
코드를 다음과 같이 사전에
-(void)notificationUserInfo:(NSDictionary *)notificationData
{
UILocalNotification *notification = [[UILocalNotification alloc] init];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd/MM/yyyy HH:mm"];
NSString *tipid = [notificationData objectForKey:@"receivedTipsId"];
NSString *currentDate = [notificationData objectForKey:@"receivedDate"];
NSString *tipsCategoryid = [notificationData objectForKey:@"categoryId"];
NSString *todayDateTime = [notificationData objectForKey:@"todayDate"];
NSString *categoryName = [notificationData objectForKey:@"categoryName"];
NSString *tipsForNotification = [notificationData objectForKey:@"tipsForNotification"];
NSString *cardType = [notificationData objectForKey:@"cardType"];
//Assigning the notification contents
NSDate *updatedDateFormat = [dateFormat dateFromString:todayDateTime];
notification.fireDate = updatedDateFormat;
notification.userInfo = [NSDictionary dictionaryWithObjectsAndKeys:tipid, @"receivedTipsId", currentDate, @"receivedDate", tipsCategoryid, @"categoryId", cardType, @"cardType", nil];
notification.alertBody = [NSString stringWithFormat:@"%@: %@",categoryName, tipsForNotification];
notification.soundName = UILocalNotificationDefaultSoundName;
notification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
감사합니다.
나는 이미 그랬다. –