简体   繁体   English

Swift UILocalNotification:显示通知时是否可以触发事件?

[英]Swift UILocalNotification: Is it possible to fire an event when Notification is displayed?

So I know the didReceiveLocalNotification event is fired when a user selects an action on a Local Notification. 因此,我知道当用户在本地通知上选择一个动作时,就会触发didReceiveLocalNotification事件。

But, is an event fired prior to that when the notification is displayed as a banner or alert when the app is not active? 但是,当通知显示为横幅广告或应用程序不活动时,是否在此事件之前触发了事件? And can that be accessed to do some background code? 可以访问它做一些后台代码吗?

I am looking for an answer in Swift if you can help. 如果您需要帮助,我正在Swift中寻找答案。

No, local notifications do not and cannot awake the app when firing and the application is not active. 不可以,在启动且应用程序未激活时,本地通知不会且无法唤醒应用程序。 The user must tap the notification, or perform a developer defined action on it before the app hears anything. 用户必须点击通知,或在应用程序听到任何声音之前对其执行开发人员定义的操作。

If you need your app to wake up, you need to use a remote notification with content available flag set. 如果您需要唤醒应用程序,则需要使用设置了内容可用标志的远程通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我打开通知托盘查看通知时,UILocalNotification会触发 - UILocalNotification fire when i open the notification tray to see the notification 调用UILocalNotification时发出警报 - fire an alert when a UILocalNotification is called UILocalNotification背景事件触发iOS中的音乐暂停 - UILocalNotification background event fire to pause Music in iOS iOS-UILocalNotification不会触发(在后台设置时) - iOS - UILocalNotification does not fire (when set in background) 我想创建一个通知,当 swift 中显示另一个通知时将触发该通知 - I want to create a notification that will be triggered when another notification is displayed in swift 在数据库中为重复事件建模,并使用UILocalNotification触发事件 - modeling a repeating event in a database, and using UILocalNotification to fire the event 可以迅速了解通知是在3发出的吗? - Is it possible to understand when a notification raised in swift 3? 定期快速触发本地通知 - Fire local notification periodically swift UILocalNotification接收带有NSYearCalendarUnit的repeatInterval的通知(将触发日期移动到下一个触发日期) - UILocalNotification receiving notification with repeatInterval of NSYearCalendarUnit (move fire date to next fire date) 访问UILocalNotification用户信息时出现Swift错误 - Swift error when accessing UILocalNotification userinfo
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM