本地通知是否可以在iOS8中触发代码? [英] Can a local notification trigger code in iOS8?

查看:70
本文介绍了本地通知是否可以在iOS8中触发代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个需要超过64个本地通知的应用。当系统在没有用户与通知交互的情况下向用户发送通知时,是否有任何触发代码的方法?

I am trying to create an app which will require more than 64 local notifications. Is there any way of triggering code when the system delivers a notification to the user without the user interacting with the notification?

推荐答案

是并且没有。

如果通知在应用程序位于前台时发送,则会将其发送给您(应用程序),而不是用户,因此您将知道以这种方式。

If the notification is delivered when the app is in the foreground, it is delivered to you (the app), not to the user, so you will know in that way.

如果在应用程序不在前台时发送,则应用程序未运行,因此没有人可以告诉。该应用程序不会启动/唤醒您只是为了告诉您通知已发生。正如您所暗示的那样,如果用户要求通知与您联系,我们会与您联系,否则,不会。

If is delivered when the app is not in the foreground, the app is not running so there is no one to tell. The app is not going to launch / wake you just to tell you that the notification took place. As you rightly imply, if the user asks the notification to contact you, you will be contacted, but otherwise, no.

但是,当应用程序到来时,您会收到一个事件再次向前看,所以你可以随时查看通知时间是否在你出去的时候。

However, you get an event when the app comes to the front once again, so you can always look to see whether the notification time happened "while you were out".

(另请注意,通知可能永远不会发送用户可以关闭通知。完全依赖它们是有风险的。)

(Also note that the notification might never be delivered to the user. The user can just turn off notifications. It is risky to rely on them completely.)

这篇关于本地通知是否可以在iOS8中触发代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆