gpt4 book ai didi

ios 第二次设置为 localnofication fireDate 它不能正常工作

转载 作者:行者123 更新时间:2023-11-29 02:43:33 25 4
gpt4 key购买 nike

请给我我正在等待的解决方案我制作了一个闹钟应用程序,我在本地通知 fireDate 上设置的闹钟时间正常工作,然后我尝试第二次(1 分钟后的贪睡时间)我无法设置本地通知,当我尝试设置第二次时时间本地通知它没有按时开火否则它会立即开火我错了这是我的代码

int getTrackValue=[[defaults valueForKey:@"alarmTrack"] intValue];
NSString *soundName =[appDelegte.globalArrayTrack objectAtIndex:getTrackValue];
// set up the notifier
UILocalNotification *localNotification = [[UILocalNotification alloc]init];

localNotification.fireDate = notiAlarmTime;
localNotification.timeZone = [NSTimeZone systemTimeZone];
localNotification.alertBody=@"Please Off Alarm";
localNotification.alertAction = NSLocalizedString(@"Show", nil);
localNotification.soundName = [NSString stringWithFormat:@"%@.m4a",soundName];//@"Gentle Rise.m4a";
localNotification.hasAction = YES;

// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

第二次我只是改变时间并调用相同的函数请帮我请分享您的宝贵知识

最佳答案

您不能在预定后立即更改 UILocalNotification,如果您想更改 fireDate,您应该取消通知重新安排它

取消通知

 int getTrackValue=[[defaults valueForKey:@"alarmTrack"] intValue];
NSString *soundName =[appDelegte.globalArrayTrack objectAtIndex:getTrackValue];
// set up the notifier

[[UIApplication sharedApplication] cancelAllLocalNotifications];
UILocalNotification *localNotification = [[UILocalNotification alloc]init];

localNotification.fireDate = notiAlarmTime;
localNotification.timeZone = [NSTimeZone systemTimeZone];
localNotification.alertBody=@"Please Off Alarm";
localNotification.alertAction = NSLocalizedString(@"Show", nil);
localNotification.soundName = [NSString stringWithFormat:@"%@.m4a",soundName];//@"Gentle Rise.m4a";
localNotification.hasAction = YES;

// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

相关问题:Delete a particular local notification

关于ios 第二次设置为 localnofication fireDate 它不能正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25428839/

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