Tag: uilocalnotification

以编程方式从通知托盘中删除UILocalNotification

有没有办法编程从通知托盘中删除/解除UILocalNotification 。 我可以取消通知,从中删除通知 [[UIApplication sharedApplication] scheduledLocalNotifications] 这是我需要做的 我需要在操作执行后(即在用户点击通知后)从NotificationTray中解除UILocalNotification , 编辑:我可以从NSNotificationCenter删除通知。 我想从Notification Tray中删除特定的通知。就像用户按下清除button清除属于特定应用程序的所有通知一样。

UILocalNotification应该在每个工作日重复一次,但是周末也会触发

我有一个UILocalNotification,应该从星期一到星期五每天一次,但不是在周末。 我认为将通知的repeatInterval属性设置为NSWeekdayCalendarUnit将完成此操作。 可悲的是,我的通知仍然在周末开火。 谁能build议为什么? 这是我的代码: UILocalNotification *localNotification = [[UILocalNotification alloc] init]; localNotification.alertAction = @"View"; localNotification.alertBody = NSLocalizedString(@"ALERT_MESSAGE", nil); localNotification.soundName = UILocalNotificationDefaultSoundName; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"MM-dd-yyyy HH:mm"]; [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"America/Toronto"]]; // Notification fire times are set by creating a notification whose fire date // is an arbitrary weekday at the correct time, […]

清除当地通知的应用徽章

我试图用UILocalNotification清除我的应用程序的“未读”徽章。 从逻辑上讲,你可能会认为这是通过将UILocalNotification实例的applicationIconBadgeNumber设置为0来完成的。但是它不起作用,applicationIconBadgeNumber的文档会说“默认值是0,这意味着”没有改变“。 那么一旦设置了本地通知,是否真的没有办法清除徽章呢? 更新:一些简单的代码: -(void)applicationDidFinishLaunching { // Set the appication icon badge to 1 in 10 minutes, using a local notification so it works in the background: // This works fine. UILocalNotification *episodeNotification = [[UILocalNotification alloc] init]; episodeNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:(60 * 10)]; episodeNotification.timeZone = [NSTimeZone defaultTimeZone]; episodeNotification.applicationIconBadgeNumber = 1; [[UIApplication sharedApplication] scheduleLocalNotification:episodeNotification]; [episodeNotification release]; […]

iOS 9:在timout之前,beginBackgroundTaskWithExpirationHandler被调用

我正在进行VOIP呼叫,并添加了对iOS <10的支持。对于应用程序处于后台的传入VOIP呼叫,我正在使用UILocalNotification(在iOS 10中不推荐使用)。 要拨打电话60秒(或1分钟),我使用此代码 count = 0; apnTimer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(showIncomingCall:) userInfo:userInfo repeats:YES]; self.backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{ NSLog(@"ALVOIP : BACKGROUND_HANDLER_NO_MORE_TASK_RUNNING."); [application endBackgroundTask:self.backgroundTask]; self.backgroundTask = UIBackgroundTaskInvalid; }]; -(void)showIncomingCall:(NSTimer *)timer { if (count < 60) { UIApplication *application = [UIApplication sharedApplication]; [application presentLocalNotificationNow:localNotification]; NSLog(@"Time Remaining: %f", [[UIApplication sharedApplication] backgroundTimeRemaining]); count = count + 3; return; […]

如何在iOS8中将通知types从Banner更改为Alert?

我试图创build一个应用程序,提供本地通知作为一个警报,而不是一个横幅。 但看起来像横幅是默认的,我无法find一种方法来改变我的代码。 我可以改变它的应用程序通知设置,它完美的作品,但我希望这种configuration是默认的。 这是我用来请求用户发送通知的权限的代码: UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil]; [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings]; (顺便问一下,有人知道为什么我不能用这个代码设置图标徽章?) 这是我用来创build本地通知的代码: UILocalNotification* localNotification = [[UILocalNotification alloc] init]; localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:segundosTotal]; localNotification.alertBody = timer.nome; localNotification.soundName = @"Default-28-sec-192kbps.mp3"; localNotification.timeZone = [NSTimeZone defaultTimeZone]; [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 有了这个代码,我得到了默认的横幅通知,我怎样才能把它更改为提醒?

UILocalNotification声音不停止播放

我已经设置了一个自定义的.aif 30秒文件作为本地通知声音名称。 下面是我的调度本地通知的代码。 //Function to schedule local notification -(void)schedulelocalnotification:(NSDate *)particularfiredate ringtone: (NSString *)particularringtone name:(NSString *)alarmname info:(NSDictionary *)dicttext { UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.fireDate = particularfiredate; notification.soundName = [arrayAIFFFiles objectAtIndex:[arraysoundfilesnames indexOfObject:particularringtone]]; notification.alertBody = alarmname; notification.userInfo = dicttext; [[UIApplication sharedApplication] scheduleLocalNotification:notification]; } 但是,当设备被locking,并且用户滑动通知进入应用程序时,即使用户进入应用程序,声音也会继续播放。 即使用户退出/卸载应用程序,它仍会继续播放。 请提出可能的原因。 – (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { [[NSUserDefaults standardUserDefaults] setValue:@"0" forKey:@"demo"]; […]

如何在特定的一周中重复本地通知(iOS Swift 3)

我正在创build我的第一个应用程序,让用户为自己设置警报,然后应用程序会在设定的时间内向用户发送本地通知。 我现在遇到麻烦的事情是能够在一周中的特定日子(例如每个星期一和星期二)发出本地通知。 到目前为止,我所遇到的所有教程/问题(如这个 )都只是关于每天/每周的安排通知。 我试图达到的理想效果就像iPhone内置的报警系统,您可以在一周中的某几天设置一个闹钟来启动。 如果我不能只设置notification.repeatInterval字段,有没有办法我可以做我想做的事情? 我可以在午夜执行一些小的代码来安排正确的通知吗? 如果是这样,我该怎么做? 提前致谢!

NSCalendarUnitWeekOfYear和NSCalendarUnitWeekOfMonth之间的区别

我想在UILocalNotification之前每周做一个UILocalNotification重复我会使用localNotification.repeatInterval = NSWeekCalendarUnit – 除了NSWeekCalendarUnit已被弃用。 文档说: “使用NSCalendarUnitWeekOfMonth或NSCalendarUnitWeekOfYear,取决于你的意思是” 但我不知道有什么不同,所以我不知道我是哪一个。

在后台10分钟后,UILocalNotification不会触发

我有一个VoIP应用程序。 哪个工作正常。 呼叫在前台和后台工作。 以下步骤完成: UIBackgroundModes =>在Info.plist中的VoIP 为VoIP使用configuration了其中一个应用套接字。 在移动到后台之前,setKeepAliveTimeout:handler:被调用 configurationaudio会话来处理转入和转出活动使用。 为了确保在iPhone上获得更好的用户体验,使用核心电话框架来调整与基于蜂窝的电话呼叫相关的行为; 为确保VoIP应用的良好性能,使用“系统configuration”框架来检测networking更改,并尽可能让应用hibernate。 现在的情况是,当应用程序在后台,一个电话来,然后UILocalNotification触发以下。 用户可以通过两个buttonCANCEL和RECEIVE看到通知 – (void)applicationDidEnterBackground:(UIApplication *)application { bgTask = [application beginBackgroundTaskWithExpirationHandler:^{ [application endBackgroundTask: bgTask]; bgTask = UIBackgroundTaskInvalid; }]; dispatch_async(dispatch_get_main_queue(), ^{ while ([application backgroundTimeRemaining] > 1.0) { NSString *friend = [self checkForIncomingChat]; if ([friend length]>0) { [[UIApplication sharedApplication] cancelAllLocalNotifications]; UILocalNotification *localNotif = [[UILocalNotification alloc] init]; if […]

iOS每日本地推送通知

我想在每天早上9:00执行一次UILocalNotification ,只要应用程序是开放的。 我发现的最接近的是: UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.fireDate = [[NSDate date] dateByAddingTimeInterval:60*60*24]; notification.alertBody = @"It's been 24 hours."; [[UIApplication sharedApplication] scheduleLocalNotification:notification]; 但是,此代码只在24小时内执行一次UILocalNotification ,而不是在指定的时间。 我一直在研究利用NSDate ,但一直没有得到的地方。 代码将在application didFinishLaunchingWithOptions方法的AppDelegate中执行。 如果有人打开应用程序并在上午8:59将其置于后台,则UILocalNotification将在上午9:00仍然执行。 一个NSDateComponent将不会工作,因为我将不得不声明年,月和日,但我想每天执行此UILocalNotification而不必编辑代码。