iOS版 - 处理无声推送通知当App被强制退出按用户 [英] iOS - Handling Silent Push Notifications When App Is Force-Quit By User

查看:395
本文介绍了iOS版 - 处理无声推送通知当App被强制退出按用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前面临的一个问题,在iOS的推送通知。

I am currently facing a problem with push notifications in iOS.

我的应用程序接收到包含一个标识符无声推送通知。然后,该标识符用于从其中创建一个本地通知远程服务器获取数据。

My app receives silent push notifications containing an identifier. This identifier is then used to fetch data from a remote server from which a local notification is created.

据我所知,如果用户有强制退出应用程序,然后无声推送通知不会被转嫁的 didReceiveRemoteNotification <(轻按两下home键和轻扫关闭应用程序,IE) / em>的方法在的AppDelegate 的类[1] [2],从而$ ​​p $不做任何处理pventing的应用程序。

As far as I'm aware, if the user has force-quit an app (i.e. by double tapping the home button and swipe closing the app) then the silent push notification does not get passed onto the didReceiveRemoteNotification method in the AppDelegate class [1] [2], thus preventing the app from doing any kind of processing.

我做的研究相当数量为处理上述情况。然而,是无法找到一个明确的答案,并希望有人能帮助我,或点我在正确的方向。

I have done a fair amount of research into handling the situation mentioned above. However, was unable to find a definitive answer and was hoping someone could help me out or point me in the right direction.

TLDR:当用户有我应该怎么做强制退出我的应用程序,但我仍然需要处理一种无声的通知

TLDR: What should I do when the user has force-quit my app, but I still need to process a silent notification?

更多信息:结果
我的应用程序只需要支持iOS8上+。

Further Information:
My app only needs to support iOS8+.

[1] <一个href=\"https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1\" rel=\"nofollow\">https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1

的通知有效载荷结果
  如果在通知到达目标应用程序没有运行,警报消息,声音或徽章值播放或显示。如果应用程序正在运行,该系统提供的通知应用程序委托作为一个NSDictionary对象。

The Notification Payload
If the target app isn’t running when the notification arrives, the alert message, sound, or badge value is played or shown. If the app is running, the system delivers the notification to the app delegate as an NSDictionary object.

[2] <一个href=\"http://stackoverflow.com/a/19202487/2472819\">http://stackoverflow.com/a/19202487/2472819

推荐答案

previously iOS中7之前,一旦用户强制退出应用程序,它将不能够运行在所有和后台任务,其中包括位置监控,推通知处理与内容提供:1。

Previously in iOS 7 and before, once a user force-quit an app, it will not be able to run and background tasks at all, including location monitoring, push notification handling with content-available:1 etc.

然而问题是,这样的行为是不记载。其原因是,它可以在新的iOS更新改变,苹果并不希望太早钉棺材。正如iOS中8, PushKit 介绍,并应该能够对付强制退出的情况。请查看本教程的详细信息: https://zeropush.com/guide/guide-到pushkit和VoIP的

However the problem is that such behavior is not documented. The reason is that it may change in a new iOS update and Apple doesn't want to nail the coffin too early. As in iOS 8, PushKit is introduced and is supposed to be able to deal with the force-quit scenario. Please check this tutorial for details: https://zeropush.com/guide/guide-to-pushkit-and-voip

这篇关于iOS版 - 处理无声推送通知当App被强制退出按用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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