如何检测发送到其他应用程序的推送通知? [英] How to detect push notification sent to other apps?

查看:155
本文介绍了如何检测发送到其他应用程序的推送通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法找到检测通知何时进入的方法。例如,如果我的应用程序已打开并且用户获得了Facebook推送通知\,是否有任何UIApplication通知或其他会告诉我的内容该应用程序不再处于前台,Facebook警报位于顶部?如果通知是横幅或警报,则最好触发某些内容

I cannot seem to find a way to detect when a notification comes in. For example, if my app is open and the user gets a Facebook push notification\, is there any UIApplication notification or something else that will tell me that the app is no longer in the foreground and the Facebook alert is on top? Preferably something that is fired if the notification is a banner or an alert

推荐答案

您无法检测发送到其他应用的推送通知。

You cannot detect a push notification sent to another app.

如果你想检测你的应用是否不在前台,你可以使用 applicationWillResignActive:方法 UIApplicationDelegate 或注册 UIApplicationWillResignActiveNotification 通知。

If you want to detect whether your app is not in foreground anymore, you can use the applicationWillResignActive: method of UIApplicationDelegate or register for the UIApplicationWillResignActiveNotification notification.

但是,当通知横幅显示在顶部时,您的应用程序仍处于前台。当通知被提示为警报时(用户可以在首选项中设置此通知),应用程序将失去焦点,它将不再处于前台。

However, when the notification banner appears on top, your application is still in foreground. When the notification is prompted as an alert instead (the user can set this in the preferences), the application loses the focus and it won't be in foreground anymore.

这篇关于如何检测发送到其他应用程序的推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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