Tag: uilocalnotification

如何在应用程序closures时在iOS中接收本地通知

我正在使用本地通知报警系统,但我在处理本地通知时遇到了一些问题,当我点击报警通知(当应用程序closures时)其启动应用程序,但问题是它应该去didFinishLaunchingWithOptionsfunction,但它不会进去appDelegate中的函数(我使用断点来检查)。 我正在使用导航控制器的故事板,我想打开一个特定的视图控制器上的应用程序closures时通知点击。 但是当我启动这个应用程序时,通常会进入didFinishLaunchingWithOptions函数。 请build议。 任何帮助,将不胜感激。 的main.m #import "DEMOAppDelegate.h" int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([DEMOAppDelegate class])); } } DEMOAppDelegate.m #import "DEMOAppDelegate.h" @implementation DEMOAppDelegate – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UILocalNotification *localNotif = [launchOptions objectForKey: UIApplicationLaunchOptionsLocalNotificationKey]; if (localNotif) { NSLog(@"Recieved Notification %@",localNotif); } return YES; } – (void)applicationWillResignActive:(UIApplication *)application […]

PhoneGap iOS LocalNotifications夏令时

我在iOS中使用(臭名昭着的) Drew Dahlman的Phonegap本地通知 。 它似乎工作。 我从来没有写过一个Objective-C的行,而不愿意(这可能是为什么我现在有麻烦!),但我认为这个插件是不正确的,想要解决它,如果可能的话。 当我在13:00设置通知时,它会正确启动。 但是,如果夏令时正在进行,通知将在14:00,晚一个小时发生。 这是因为时区没有被考虑在内吗? 德鲁提到时区被设置为+0000不是一个问题,但这是错误的信息? 我应该更新插件来处理时区和夏令时? 或者在我自己的代码中处理夏令时,并简单地设置DST为活动状态时的date-1小时? 我想我必须在LocalNotification.m中更新这些行的第二行,但正如我所说,我不确定要更新到哪一行 。 UILocalNotification *notif = [[UILocalNotification alloc] init]; notif.timeZone = [NSTimeZone defaultTimeZone];

UILocalNotification没有做任何事情

这可能看起来像一个愚蠢的问题,但这是我第一次使用UILocalNotification,我不能得到它的工作进行一个快速的testing。 它只是没有做任何事情。 1.我在AppDelegate中创build了两个variables let today = NSDate() let notification: UILocalNotification = UILocalNotification() 2.然后在applicationDidEnterBackground函数中,我有以下几点 notification.fireDate = today.dateByAddingTimeInterval(10) notification.alertTitle = "My App Test" notification.alertBody = "Testing Notification \n :)" UIApplication.sharedApplication().presentLocalNotificationNow(notification) UIApplication.sharedApplication().scheduleLocalNotification(notification) 3.还将此添加到applicationDidBecomeActive函数中 UIApplication.sharedApplication().cancelAllLocalNotifications()

iOS – UILocalNotification为相同的通知激发了两次

如果我安排两个UILocalNotification并设置它们都在同一个fireDate上触发。 然后在设备上(这不是模拟器的bug)在fireDate application:didReceiveLocalNotification: didReceiveLocalNotification application:didReceiveLocalNotification:将会触发4次(每次通知2次)。 这是一个已知的错误? 因为我一直没有find任何有关它的信息。

为什么本地通知在重复间隔设置为1秒(NSSecCalendarUnit)1分钟后重复?

我试图安排一次当地的通知,一旦通知被解雇,将在每隔1秒后重复。 通知在应用程序启动10秒后触发。 UILocalNotification *notif = [[cls alloc] init]; notif.fireDate = [[NSDate alloc]initWithTimeInterval:10 sinceDate:[NSDate date]]; notif.timeZone = [NSTimeZone defaultTimeZone]; notif.alertBody = @"Did you forget something?"; notif.alertAction = @"Show me"; //notif.soundName = UILocalNotificationDefaultSoundName; notif.soundName = @"applause-light-01.wav"; notif.applicationIconBadgeNumber = 1; notif.repeatInterval = NSSecondCalendarUnit; [[UIApplication sharedApplication] scheduleLocalNotification:notif]; 甚至认为我已经使用notif.repeatInterval = NSSecondCalendarUnit ,通知60秒后重复。 我做错了什么?

iOS – 本地通知 – cancelAllLocalNotifications

可能是一个简单的问题:当我打电话给“cancelAllLocalNotifications”,它是否取消通知应用程序创build的唯一或它将取消所有其他应用程序的通知也?

didReceiveLocalNotification方法在应用程序处于后台时未在应用程序委托中调用

我添加了一个本地通知,它也被触发,通过在iOS6上显示一个横幅并在iOS5中显示警报。 但是在iOS6中,app delegate中的“ didReceiveLocalNotification ”方法没有被调用。 如何知道当应用程序在后台时发生通知? 谢谢。

与各种警报机构的UILocalNotification

如何重复UILocalNotification与各种警报机构? 例如: UILocalNotification *notif = [[UILocalNotification alloc] init]; notif.alertBody = @"Hello"; notif.repeatInterval = NSDayCalendarUnit; [[UIApplication sharedApplication] scheduleLocalNotification:notif]; 通过使用这个代码,通知将会每天重复,我怎样才能每天重复通知不同的警报机构? 谢谢。

cancelAllLocalNotifications在iOS10中不起作用

我想在添加新的通知时从通知中心删除所有以前的本地通知。 但它在iOS9.0和更低版本中工作,但在iOS 10中,它触发多个本地通知。 所以看起来像cancelAllLocalNotifications不清除通知。 代码在iOS10中成功编译。 UIApplication.shared.cancelAllLocalNotifications()

如何获得已经发射的UILocalNotification

我在我的应用程序中实现UILocalNotification ,并按预期发送通知。 据我所知,通知是这样处理的: 当应用程序没有运行,并且用户点击通知时, applicationDidFinishLaunching通过applicationDidFinishLaunching方法中的选项接收通知。 当应用程序处于活动状态时,它通过didReceiveLocalNotification方法接收通知。 当应用程序在后台,并且用户单击通知时,它通过didReceiveLocalNotification方法接收通知。 但有一种情况我一直无法覆盖,那就是当一个通知被触发,应用程序在后台,而应用程序只是通过点击应用程序图标(而不是点击通知)来激活。 在这种情况下,没有可用的UILocalNotification 。 但是我仍然想知道自从上次激活通知以来,通知已经触发了,因为通知中有一些信息要在它的userInfo属性中执行。 目前我已经通过检查applicationDidBecomeActive中的徽章号是否为0来“解决”它,但是这只允许我向用户显示一般消息。 我宁愿能够知道什么通知导致徽章号码更新。 有什么办法可以做到这一点?