gpt4 book ai didi

ios - 为什么我的本地通知没有在所需时间启动或根本没有启动

转载 作者:行者123 更新时间:2023-11-29 12:35:20 24 4
gpt4 key购买 nike

- (IBAction)hitAlarm:(id)sender {
UILocalNotification *localNotif = [[UILocalNotification alloc] init];

NSDateFormatter *formatter;
NSString *dateString;

formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"dd-MM-yyyy HH:mm"];

dateString = [formatter stringFromDate:_timePicker.date];
NSLog(@"%@",dateString);


[localNotif setFireDate:_timePicker.date];
[localNotif setRepeatInterval:NSCalendarUnitDay];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
NSLog(@"Hit Button");
}

这是一种设置警报的方法,该警报将在指定时间创建本地通知。然而,当它应该创建一个通知的时候到了,它似乎没有。没有给定的错误消息,它似乎根本没有传递通知。为什么会这样?

最佳答案

在 iOS8 上,您必须调用 [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; 以获得显示后台通知的权限。

关于ios - 为什么我的本地通知没有在所需时间启动或根本没有启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26521831/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com