[英]Handle local notification in background and suspended
I want to perform some task when local notification fired(assume application is in background/suspended but not in foreground) without taping user on notification. 我想在触发本地通知时执行一些任务(假设应用程序在后台/挂起,但不在前台),而无需在通知上点击用户。 How it possible??. 怎么可能? i am not able to get delegate in application:didReceiveLocalNotification: in case of application is in background/suspended and Local Notification fired. 我无法在application:didReceiveLocalNotification中获得委托:如果应用程序处于后台/挂起状态且触发了本地通知,则无法使用。 Please any one can suggest some solution. 请任何人可以提出一些解决方案。 Thanks in advance. 提前致谢。
The didReceiveLocalNotification
method is only called when you application is running in the foreground. 仅当应用程序在前台运行时才调用didReceiveLocalNotification
方法。 If you see a badge and click on the App to start it, then you need to process the local notification using application:willFinishLaunchingWithOptions:
(or application:didFinishLaunchingWithOptions:
) To get at your local notification in either of these two methods, use UIApplicationLaunchOptionsLocalNotificationKey
as a key to the options dictionary. 如果看到徽章并单击应用程序以启动它,则需要使用application:willFinishLaunchingWithOptions:
或application:didFinishLaunchingWithOptions:
application:willFinishLaunchingWithOptions:
处理本地通知,要以这两种方法之一获取本地通知,请使用UIApplicationLaunchOptionsLocalNotificationKey
作为选项字典的键。
If your app is in suspended state, you won't be able to know that the notification is fired. 如果您的应用处于暂停状态,则您将无法知道该通知已被触发。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.