简体   繁体   English

检测应用何时收到推送远程通知

[英]Detect when app receive a push remote notification

how can I handle a remote notification without opening the app (when the banner appear on the screen) 如何在不打开应用程序的情况下处理远程通知(当横幅显示在屏幕上时)

I tried a lot of methods and they are called only when I tap on the notification 我尝试了很多方法,只有在我点击通知时才调用它们

If your app needs to analyze push notification without, user tapping on it, you need to set content-available=1 in your push notification,you get the push data in 'didReceiveRemoteNotification' function in your AppDelegate. 如果您的应用程序需要分析推送通知,而无需用户点击它,则需要在推送通知中设置content-available = 1,您可以在AppDelegate的'didReceiveRemoteNotification'函数中获取推送数据。 but you need to consider something, even with this method, there is no guarantee that your application get the push notification data, Your application get the push's data only when your application is in foreground or your app is in background but IOS system is not idling your application otherwise your app is not going to get the push notification from IOS. 但是即使使用这种方法,您也需要考虑一些问题,不能保证您的应用程序获得推送通知数据,仅当您的应用程序位于前台或应用程序处于后台但IOS系统没有空闲时,您的应用程序才能获取推送的数据您的应用程序,否则您的应用程序将无法从IOS接收推送通知。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM