Tag: uilocalnotification

每14天(两周)后重复本地通知?

在我的应用程序中,我必须设置重复的UILocalNotification 。 我可以通过做每日,每周等设置repeatInterval UILocalNotification *localNotification = [[UILocalNotification alloc] init]; localNotification.repeatInterval = NSDayCalendarUnit; // or any other calendarUnit 好吧,没关系,但是我必须每14天设置一次repeatInterval。 我从这个链接中知道我们只能使用NSCalendarUnit重复间隔之一。 所以你可以有一分钟或一小时或一天,但不是五分钟或三小时或十四天的重复间隔。 任何有关iOS 5或更高版本(该文章是为iOS 4.0编写的)限制的想法?

应用程序:didReceiveLocalNotification永远不会调用ios 8

是否有任何已知的问题: application:didReceiveLocalNotification delegate 在iOS 8上? 我的应用程序使用UILocalNotification创build本地通知。 当应用程序在后台我收到通知,当我点击通知横幅,它移动到我的应用程序。 但是这个方法: -(void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification 永远不会在iOS 8(Xcode 5.1.1)上调用,但在iOS 7或更早版本中运行良好。 PS我也testing过这个网站的项目: http : //www.appcoda.com/ios-programming-local-notification-tutorial/ ,它不适用于iOS 8。

如何在用户通知中设置重复频率

直到iOS 9我们写这样的local notifications UILocalNotification* localNotification = [[UILocalNotification alloc] init]; localNotification.fireDate = pickerDate; localNotification.alertBody = self.textField.text; localNotification.timeZone = [NSTimeZone defaultTimeZone]; localNotification.repeatInterval = NSCalendarUnitMinute; localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1; [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 并在本地通知我们有repeatInterval ,现在在WWDC2016苹果宣布其中包含User Notification UNTimeIntervalNotificationTrigger。 UNCalendarNotificationTrigger。 UNTimeIntervalNotificationTrigger* trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:60 repeats:YES]; 上面的代码会在每分钟后触发通知。 但是不能设定date。 NSDateComponents* date = [[NSDateComponents alloc] init]; date.hour = 8; date.minute […]

当应用程序从iOS中的本地通知进入前景时触发特定的操作? (使用swift)

我正在使用新的语言Swift构build一个iOS应用程序。 现在它是一个HTML5应用程序,它使用UIWebView显示HTML内容。 该应用程序有本地通知,而我想要做的就是在应用程序通过点击(触摸)本地通知进入前景时在UIWebView中触发一个特定的javascript方法。 我已经看过这个问题 ,但似乎并没有解决我的问题。 我也遇到这个问题 ,告诉我使用UIApplicationState,这是好的,这将帮助我知道应用程序从通知进入前台。 但是,当应用程序恢复,如何调用应用程序恢复时显示的视图的viewController中的方法? 我想要做的是得到我的ViewController的一个实例,并在其中设置一个属性为true。 如下所示 class FirstViewController: UIViewController,UIWebViewDelegate { var execute:Bool = false; @IBOutlet var tasksView: UIWebView! } 而在我的AppDelegate我有方法 func applicationWillEnterForeground(application: UIApplication!) { let viewController = self.window!.rootViewController; let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) var setViewController = mainStoryboard.instantiateViewControllerWithIdentifier("FirstView") as FirstViewController setViewController.execute = true; } 所以我想要做的是当应用程序再次进入前台时,我想查看执行variables并运行方法如下, if execute{ tasksView.stringByEvaluatingJavaScriptFromString("document.getElementById('sample').click()"); } […]

如何从自定义类创build和取消唯一的UILocalNotification?

目前我有一个闹钟定时器(本地通知)。 我想从这个代码创build一个计时器类来创build多个计时器和通知(最多5个),我正在努力如何创build和取消与类方法的唯一通知。 – (UILocalNotification *) startAlarm { [self cancelAlarm]; //clear any previous alarms alarm = [[UILocalNotification alloc] init]; alarm.alertBody = @"alert msg" alarm.fireDate = [NSDate dateWithTimeInterval: alarmDuration sinceDate: startTime]; alarm.soundName = UILocalNotificationDefaultSoundName; [[UIApplication sharedApplication] scheduleLocalNotification:alarm]; } 我的假设是,如果我有一个类方法创build一个名为“警报”的UILocalNotification iOS会看到所有的通知是相同的通知,下面的方法将不会按照我希望的方式运行: – (void)cancelAlarm { if (alarm) { [[UIApplication sharedApplication] cancelLocalNotification:alarm]; } } 所以我需要一种方式来命名这些UILocalNotifications,因为它们被创build,例如alarm1 alarm2 … alarm5,所以我可以取消正确的。 提前致谢。

非主要捆绑文件作为警报声音

我希望我错了,但我不认为这是可能的。 在“本地和推送通知编程指南”中的“准备自定义警报声音”下,它说“声音文件必须位于客户端应用程序的主包中”。 如果您不能写入主包,那么如何获得用户生成的录音(使用AVAudioRecorder)作为警报声? 一方面它似乎是不可能的,但另一方面,我认为有应用程序在那里做(我会寻找那些)。

iOS 8 .scheduledLocalNotifications为空

我试图更新我的应用程序到iOS 8.在一个函数中,我安排了一个本地通知(我已经检查过,通知的所有其他部分是正确的)以这种方式: [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 那么我使用这个代码打印预定的本地通知: NSLog(@"notifications %@", [UIApplication sharedApplication].scheduledLocalNotifications ); 但arrays [UIApplication sharedApplication].scheduledLocalNotifications 即使通知未被触发,也是空的。 然后,为了检查本地通知是否真的计划好了,我试着使用这个代码 NSLog(@"notification appdelegate %@", application.scheduledLocalNotifications ); 在函数中 – (void)applicationWillResignActive:(UIApplication *)application 在这种情况下, Appdelegate.m的计划本地通知数组不是空的,NSLog函数打印正确的通知。 这只发生在真实的设备上,在模拟器我的应用程序工作正常。 问题是不检查用户的权限来安排本地通知,因为我已经面对它。 有人可以帮我吗? 一些想法?

每周在特定的date和时间发出通知

我想在每个星期天的晚上8点触发一个UILocalNotification ,不过,我每天晚上8点都有一个启动date。 NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDate *now = [NSDate date]; NSDateComponents *componentsForFireDate = [calendar components:(NSYearCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit| NSSecondCalendarUnit | NSWeekdayCalendarUnit) fromDate: now]; [componentsForFireDate setWeekday: 1] ; //for fixing Sunday [componentsForFireDate setHour: 20] ; //for fixing 8PM hour [componentsForFireDate setMinute:0] ; [componentsForFireDate setSecond:0] ; NSDate *fireDateOfNotification = [calendar dateFromComponents: componentsForFireDate]; UILocalNotification […]

UILocalNotification自定义声音不在iOS7中播放

我在应用程序中使用UILocalNotification 。 在应用程序中有两个有条件播放的声音 – 我已经为它们应用了适当的条件。 但是,当我安装应用程序并在iOS 7设备上运行它时,它会触发本地通知,但声音不在应用程序中播放。 下面给出的代码来设置通知: UILocalNotification *localNotification = [[UILocalNotification alloc] init]; if (localNotification == nil) return; localNotification.fireDate = [pickerView date]; localNotification.timeZone = [NSTimeZone defaultTimeZone]; if (alarm_number == 1) { localNotification.alertBody = [NSString stringWithFormat:@"First Alarm"]; } else { localNotification.alertBody = [NSString stringWithFormat:@"Second Alarm"]; } localNotification.alertAction =@"Ok"; NSString *message = [[NSString alloc]initWithString:@""]; if(alarm_number == […]

本地通知“didReceiveLocalNotification”调用两次

我正在处理本地通知使用: – (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif 并安排本地通知: – (void)scheduleNotificationWithInterval:(int)minutesBefore { UILocalNotification *localNotif = [[UILocalNotification alloc] init]; if (localNotif == nil) return; NSDate *fireDate = [NSDate date]; localNotif.fireDate = [fireDate dateByAddingTimeInterval:minutesBefore*60]; localNotif.timeZone = [NSTimeZone defaultTimeZone]; localNotif.repeatInterval = kCFCalendarUnitMinute; localNotif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"LocalEvent notification in %i minutes.", nil),minutesBefore]; localNotif.alertAction = NSLocalizedString(@"View Details", nil); localNotif.applicationIconBadgeNumber = 1; NSDictionary […]