如何处理多个推送通知用户数据到达不同的时间? [英] How to handle multiple push notifications with user data arrived at different times?

查看:235
本文介绍了如何处理多个推送通知用户数据到达不同的时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序接收从服务器发送到后端苹果的APN。当然一旦通知到达用户的设备的用户可能无法打开的应用程序。在此期间我的服务器可能会推动更多的通知。它们都包含在处理的通知是重要的一些用户数据。那么该如何处理呢? iOS版不会捆绑,并给我一个批次,会吗?

My app is receiving APNs sent from server to Apple backend. Naturally a user may not open the app once a notification arrives to user's device. In meantime my server may push more notifications. They all contain some user data that is important when a notification is processed. So how to deal with it? iOS won't bundle and give me a batch, will it?

下面一些方法,我如何去解决它,其中没有一个是简单的。

Here are ways how I am going to tackle it, none of which is simple.


  1. 服务器跟踪没有看到数据,并在到达一个新的请求总是发送了一批全新的通知,反映了算作徽章计数。

  2. 客户端是通过对录音通知弹出打开。在这种情况下,它在 didReceiveRemoteNotification 所有需要的数据。

  3. 客户端忽略了通知弹出窗口并通过点击应用程序图标,打开应用程序(可能更高)。在这种情况下 didReceiveRemoteNotification 不叫,因此应用程序必须从服务器获取所有所需的数据。

  4. 服务器永远不会发送任何用户数据和客户端总是新的东西会在每次启动或 didReceiveRemoteNotification 获取数据时检查。

  1. Server keeps track of not seen data and upon arriving a new request always sends a batch of all new notifications, reflecting the count as badge count.
  2. Client is opened by taping on notification popup. In this case it has all needed data in didReceiveRemoteNotification. OR
  3. Client ignores notification popup and opens app (possibly later) by tapping on app icon. In this case didReceiveRemoteNotification is not called and thus app has to fetch all needed data from server. OR
  4. Server never sends any user data and client always checks for new stuff every time it starts or fetches data in didReceiveRemoteNotification.

还有别的吗?简单的东西我失踪?

Anything else? Something simpler I am missing?

推荐答案

4号是正确的做法。谁也不能保证,当接收到APN,除了在iOS7您的任何应用程序code的运行。所以,你的应用程序启动时,它与您的服务器来检查任何新的信息,它应该显示。

Number 4 is the right approach. There is no guarantee that any of your app code will run when an APN is received, except on iOS7. So when your app starts, it has to check with your servers for any new information that it should display.

这是最简单的,以code这的送花儿给人的问你的服务器的最新信息显示,而不是依赖于在APN的信息。利用这些信息在APN只确定导航到新的信息,这样无论用户拍了拍上的应用程序的显示。

It's simplest to code this to alway ask your servers for the latest information to display, rather than rely on the information in the APN. Use the information in the APN only to determine which new information to navigate to, so that the app displays whatever the user tapped on.

这已经与iOS7,在那里你可以使用远程通知后台模式,只要一推邮件到达上马改变。见<一href=\"https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:didReceiveRemoteNotification:fetchCompletionHandler\" rel=\"nofollow\">https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:didReceiveRemoteNotification:fetchCompletionHandler:

This has changed with iOS7, where you can use the remote-notification background mode to be launched whenever a push message arrives. See https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:didReceiveRemoteNotification:fetchCompletionHandler:

这篇关于如何处理多个推送通知用户数据到达不同的时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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