如果我安排两个UILocalNotification
s并将它们设置为在相同的fireDate触发。然后在设备上(这不是模拟器错误)在fireDate application:didReceiveLocalNotification:
将触发4次(每次通知2次)。这是一个已知的错误?因为我一直无法找到任何有关它的信息。iOS - UILocalNotification针对相同的通知发射两次
3
A
回答
1
请将bug报告给http://bugreport.apple.com。
话虽如此,之前已经注意到,虽然有模拟器中的错误,但在设备上似乎也存在错误。
参见这太问题的意见和答案:local notification "didReceiveLocalNotification" calls twice
0
试试这个它的工作在我的应用程序:
-(IBAction)setRemind:(id)sender{
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
NSDateFormatter *dateFormatter2 = [[NSDateFormatter alloc] init];
[dateFormatter2 setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
//Gets our picker
NSDate *selectedTime = [datePicker date];
strDate2 = [dateFormatter2 stringFromDate:selectedTime];
NSDate *Date=[dateFormatter2 dateFromString:strDate2];
NSDateComponents *dateComponents = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:Date];
// Set up the fire time
NSDateComponents *dateComp = [[NSDateComponents alloc] init];
[dateComp setDay:[dateComponents day]];
[dateComp setMonth:[dateComponents month]];
[dateComp setYear:[dateComponents year]];
[dateComp setHour:9];
[dateComp setMinute:00];
[dateComp setSecond:00];
[dateComp release];
NSDate *date = [calendar dateFromComponents:dateComp];
[self scheduleAlarmForDate:date message:txtDescri.text];
}
-(IBAction)scheduleAlarmForDate:(NSDate*)date message:(NSString*)msg
{
//====== TO SEE OLD NOTIFI=======
UIApplication *Ap = [UIApplication sharedApplication];
NSArray *arr = [Ap scheduledLocalNotifications];
NSLog(@"Old Notifications :>> %@",arr);
UIApplication* app = [UIApplication sharedApplication];
UILocalNotification *alarm = [[UILocalNotification alloc] init];
// Create a new notification
alarm.fireDate = date;
NSLog(@"fireDate IS >> %@", alarm.fireDate);
alarm.timeZone = [NSTimeZone localTimeZone];
alarm.alertBody = msg;
NSLog(@"msg IS >> %@",msg);
alarm.alertAction = @"Show";
alarm.repeatInterval = 0;
alarm.soundName = UILocalNotificationDefaultSoundName;
alarm.applicationIconBadgeNumber = 1;
[app scheduleLocalNotification:alarm];
[alarm release];
}
我希望这对您有所帮助。
相关问题
- 1. 相同推送通知显示两次
- 2. jquery通知事件发射两次
- 3. UILocalNotification不发送通知
- 4. 巢映射两次相同的类型
- 5. 如何每两周通知UILocalNotification
- 6. iOS通知显示两次默认和我的通知警报
- 7. ios keyboardwillshow通知发射迟到
- 8. UILocalNotification触发多次
- 9. 通知后UILocalNotification显示视图发生?
- 10. android通知两次启动相同的活动
- 11. UILocalNotification - 需要提醒/通知
- 12. MouseLeftButtonDownEvent发射两次
- 13. quartz.net发射两次
- 14. UIGestureRecognizer发射两次?
- 15. SelectionIndexChanged发射两次
- 16. iOS 10请求通知权限触发两次
- 17. 发送相同的短信两次
- 18. UILocalNotification当我打开通知托盘查看通知时触发
- 19. 两次添加相同的对象
- 20. 我得到两次相同的对象
- 21. 发送了两次Firebase推送通知
- 22. iOS开发:推送通知,防止我的本地通知从发射
- 23. UILocalNotification或推送通知
- 24. UILocalNotification - 通知不显示
- 25. Firebase针对相同的查询返回不同的结果。 iOS
- 26. Reactjs函数发射两次?
- 27. iPad touchstart发射两次
- 28. 脚本发射两次
- 29. ASP.NET Page_Init发射两次!
- 30. ASP.net c#page_load发射两次?