Tag: uilocalnotification

Swift 3本地通知不会触发

我有以下设置,并没有任何通知是在所有的射击。 根据堆栈上的其他类似问题,我已经为每个请求添加了一个唯一的标识符,并且还将内容添加到了内容中。 我有这个要求用户许可的function。 func sendIntNotifications() { //1. Request permission from the user UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound], completionHandler: { (granted, error) in if granted { print ("Notification access granted") } else { print(error?.localizedDescription) } UNUserNotificationCenter.current().delegate = self }) // This function has a lot of other code that then calls this function to set multiple notifications […]

本地通知停止工作,不知道为什么

去年有一段时间,我在本地的iOS项目上收到了一些通知,然后在几个星期前回来的时候,我发现他们不再工作了。 我已经挖了几天,我完全被困住了。 通过后台提取,徽章仍能正常更新,但不再发送通知提醒。 这里是我有testing的最小设置。 AppDelegate中: func application(application: UIApplication, willFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool { application.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum) application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Badge, .Alert], categories: nil)) return true } func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) { let localNotification = UILocalNotification() localNotification.alertAction = "Message" application.presentLocalNotificationNow(localNotification) completionHandler(.NoData) } 我试过的东西: 卸载/重新安装应用程序(设备和模拟器) 更改捆绑标识符 禁用/重新启用后台提取function 通过添加fireDate属性呈现延迟的本地通知 尝试willFinishLaunchingWithOptions和didFinishLaunchingWithOptions 我debugging了它,100%肯定performFetchWithCompletionHandler执行时,我模拟背景获取和presentLocalNotificationNow调用 build立: Xcode 7.3.1(从以前的版本开始,可能是6.xx) Swift […]

UIApplication cancelAllLocalNotifications在应用程序更新之间如何工作?

有谁知道如何在UIApplication cancelAllLocalNotifications方法工作? 我想知道如何iOS知道如何取消。 它是否知道通过应用程序ID? 或者它以某种方式使用应用程序的版本号? 我现在正在经历的是比我预期更多的通知。 这是工作stream程: 取消应用程序启动的所有通知 在应用退出时安排通知 *计划时,将通知信息添加到“最近”列表中 *计划时,每天只安排一个通知(在断开手机之前在XCode中的日志logging中进行validation)。 现在,这正是我所经历的: 每天接收4个通知 只有一个通知显示在我的“最近”列表中(这是有道理的,因为这就是我所安排的) 以前,我每天的通知数设置为3.然后我更新了版本号(比如从1.1.0到1.1.1),调用了“cancelAllLocalNotifications”方法。 所以,如果取消通知是以任何方式基于应用程序的版本/软件包ID,我会收到旧通知以及新的通知。 但是,如果不是,并且iOS知道从先前版本1.1.0中取消预定的通知,那么我不知道这些额外的通知来自哪里。

预定的本地通知在切换为closures时切换为开启时间段

我每天早上八点半在下午一点钟通知你。 当“通知”在“设置”应用中closures一周时,通知不会显示,这是完美的。 问题是,在那个星期之后, 通知在“设置”应用程序中重新开启 ,前一周的所有通知都会显示出来 。 我想知道如何让通知不“build立”这么说。 是否有一行代码我错过了在这里“清除”? ViewController.m : – (void)viewDidLoad { [super viewDidLoad]; UILocalNotification* localNotification = [[UILocalNotification alloc] init]; NSCalendar *cal = [NSCalendar currentCalendar]; NSDateComponents *comp = [cal components:(NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute) fromDate:[NSDate date]]; comp.hour = 20; // 19 = 7PM 20=8pm comp.minute = 30; // 7:45 PM […]

pipe理多个UILocal通知

我已经创build了多个UI本地通知,比如说100.我有一个UILocalNotifications数组,计划如下: -(void) scheduleNotification{ AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; NSDateFormatter *formatter = [[NSDateFormatter alloc]init]; [[UIApplication sharedApplication] cancelAllLocalNotifications]; [self.notifications removeAllObjects]; for (int i = 0; i< [delegate.viewController.contactList count] ; i++) { UILocalNotification *localNotification = [[UILocalNotification alloc] init]; NSString *name = [[delegate.viewController.contactList objectAtIndex:i]objectForKey:NAME_KEY]; NSString *birthday = [[delegate.viewController.contactList objectAtIndex:i]objectForKey:BIRTHDAY_KEY]; if (birthday) { [formatter setDateFormat:@"MM/dd/yyyy"]; [formatter setLocale:[NSLocale currentLocale]]; […]

在数据库中build模重复事件,并使用UILocalNotification来触发事件

我不知道这是如何工作的,但我想要的是类似苹果公司的iPhone闹钟。 它基本上只是让你select一个闹钟的时间,给闹钟命名,然后你可以select你想要重复的周期(周日到周六)。 根据您的select,报警会触发一次或重复一次。 在我的核心数据模型中,我不确定如何build模。 如果我只是用简单的旧对象来思考,我会想我会有一些报警对象,其中一个属性是一个数组。 在那个arrays中,我可以获得星期天 – 星期三的date值。 然后,当一个新的报警对象被创build,我会安排一个UILocalNotification所select的时间,以及select的日子。 以数据库对象来build模,我不知道我该怎么做。 我在想像这样的东西: 闹钟 – (名称/string)日 – (星期天 – 星期六/用整数0-6,1表示到闹钟到日子的多种关系) 假设在数据库中没问题,那么我不知道应该如何安排UILocalNotifications,因为我认为每个应用只能有64个。 我想我可以有一些机制来安排前64个可能的警报,然后当应用程序打开时,它只是重新安排下一个即将到来的64个事件。 那是我该怎么做的? 谢谢。

UIApplicationLaunchOptionsLocalNotificationKey始终为空 – iOS

我有一个使用本地通知的iOS应用程序。 当应用程序在后台运行或处于活动状态时,我使用application didReceiveLocalNotification方法,这很好。 但是,当应用程序closures(不在后台运行)时,我使用application didFinishLaunchingWithOptions方法来控制通知处理时发生的情况。 但是,我didFinishLaunchingWithOptions的问题是didFinishLaunchingWithOptions方法中的通知总是(null) 。 这是我的代码: -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. // Register the app for local notifcations. if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil]]; } // Setup the local notification check. UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; //UIAlertView *alertView = […]

我可以设置UILocalnotification重复每个月的最后一天吗?

我想亲自尝试一下,但需要一个月才能确定。 任何人都试过这个? NSDate *fireDate = // Date I want to repeat, in this case 31 may localNotification.fireDate = fireDate; localNotification.repeatInterval = NSMonthCalendarUnit; [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 我希望它在每个月的最后一天提醒。 这是一种方式吗? 如果我安排在30天的月份,第二天是31日的月份,如4月 – > 5月,我应该怎么做,因为我只能设置到4月30日(也是2月28日和29日的问题)

iOS – 如何知道本地通知是否导致我的应用程序进入前景?

我有我的应用程序委托的代码 application:didReceiveLocalNotification: 方法来显示一个UIAlertView的本地通知,每当我的应用程序在前台。 如果我的应用程序在本地通知到达后的背景中,则用户会看到通知,并可以通过select该应用程序来启动应用程序。 在这种情况下,我的应用程序来到我的应用程序委托的前台 applicationWillEnterForeground: 叫做。 之后,虽然我的didReceiveLocalNotification方法再次被调用,导致一个UIAlertView再次出现。 但实际上用户已经有了这个警报,而应用程序在后台,所以理想情况下,我不想再次显示此警报。 我可以看到,如果一个应用程序是由于本地通知,然后在内部启动 application:didFinishLaunchingWithOptions: 方法可以检查一个键的启动选项 UIApplicationLaunchOptionsLocalNotificationKey 要知道本地通知是否导致您的应用程序启动,但似乎没有这样的方法,当您通过与本地通知进行交互的用户刚回到前台时,找不到这种方法。 检查我的applicationWillEnterForeground方法是否最近被调用似乎是一个hacky方式解决这个问题,或者可能类似于这个问题的答案“ iOS如何判断应用程序正在运行的前景或背景? ”将允许我检查 [UIApplication sharedApplication].applicationState 从我的内部 application:didReceiveLocalNotification: 方法。 希望它会被收到足够早,我的applicationState仍然不会被设置为UIApplicationStateActive在这种情况下。 或者有没有更好的解决scheme呢? 干杯

iOS – 本地通知 – 自定义振动或振动更长的时间

我正在尝试构build一个iPhone应用程序,其function类似于闹钟,我正在使用UILocalNotification 问题 我想电话振动更长的时间。 但目前它只振动一次。 替代方法 是否可以使用自定义振动模式?(http://www.pcworld.com/article/242238/how_to_use_custom_vibrations_in_ios_5.html) 当推送通知被触发时,是否有可能执行一个方法? (但应用程序可能甚至没有运行,但它需要工作) NSTimer是一个选项吗? (但应用程序可能甚至没有运行,但它需要工作) 还有其他的替代吗?