如何知道推送通知传递状态 [英] How to know Push Notification delivery status

查看:72
本文介绍了如何知道推送通知传递状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用中使用推送通知。一切都很顺利。

I am using push notification in an app. Everything is going fine.

有时从服务器发送消息但在应用程序端发送的消息却没有收到。

Sometimes message sent from server but in app side it does not receive.

In这种情况我必须知道哪些消息丢失(应用程序没有收到)。

In this situation I have to know which message is missing to deliver(app did not receive).

有没有办法从服务器端知道应用程序收到哪条消息哪些不是?

Is there any way to know from server side which message is received by app and which are not?

推荐答案

不推荐,推送通知即刻即发。



Apple不会告诉您以下内容:

Nopes, push notifications are fire-and-forget.

Apple will not tell you the following:


  1. 无法判断消息是否已发送是否成功

  2. 不会告诉用户是否选择了推送通知

  3. 还有很多其他事情,但无论如何......






然而



另一方面,当用户选择推送通知时,您的应用可以在一定程度上处理此问题:


However

On the other hand, when the user has opted for Push Notifications then your app can handle this but to a certain extent:

基本上,您可以在中添加逻辑 - didReceiveRemot eNotification: -didFinishLaunchingWithOptions:联系您的服务器并告诉您的服务器已收到该消息。

如果它不是在特定的时间段内收到,然后你可以重新发送它。

Basically, you could add logic in the -didReceiveRemoteNotification: and -didFinishLaunchingWithOptions: to contact your server and tell your server that the message was received.
If it wasn't received within a particular time slot then you can resend it.

但如你所见,这可能会导致一个无辜的用户充满洪水的可能情况相同的推送通知。

从某种意义上说,骚扰他点击你的愚蠢推送通知,这反过来可能导致你完全关闭你的应用程序的推送通知,但大多数时候ze会删除应用程序,甚至可能给它一个低评级?

服务对你,我会说。

But as you see, this could lead to a possible scenario of flooding an innocent user with the same push notifications.
In a sense, harassing him to tap your stupid push notification, which in turn may lead ze to switch off push notifications for your app entirely but mostly ze would delete the app and maybe even give it a low rating?
Serves you right, I'll say.

无论如何,如果你继续这样做,你需要实现一个识别模式,你插入一个唯一的消息标识符进入推送通知的有效负载,当你的应用获得此推送通知时,它应该将此消息标识符发送回服务器。

您的然后,服务器应记录特定设备令牌返回消息标识符,这意味着它收到了该特定推送通知。

Anyways, if you go ahead with this, you would need to implement an identification pattern where you insert a unique message identifier into the payload of the push notification and when your app gets this push notification, it should send this message identifier back to the server.
Your server should then log that a particular device token returned a message identifier, which means it received that particular push notification.

您的服务器可以每小时/每天/不论来检查,并将特定消息重新发送到那些未使用相对消息标识符报告的设备令牌。

Your server can check on a hourly/daily/whateverly basis and resend a particular message to those device tokens that have not reported back with the relative message identifier.

同样,这意味着您的服务器有时可能需要工作OT。

Again, this means your server might need to work OT sometimes.

这整个方法还有其他问题:

There are other issues with this whole approach:


  1. 用户收到推送通知但是解雇它而不是用它打开你的应用程序

    • 您的服务器将假定用户没有看到推送通知并将再次发送此推送通知


  • 用户接受推送通知,但稍后撤销了这个privelege

  • 用户卸载了应用
  • li>
  • 基本上,曾经用于接收推送通知但不再使用的设备令牌,很可能是由于您的消息泛滥声誉

  • User accepted push notifications at first but later revoked this privelege
  • User uninstalled the app
  • Basically, device tokens that once use to receive push notification but no longer do, most probably due to your message flooding reputation

  • 可能会多次获得相同的推送通知(非常恼人

  • might get same push notification multiple times (very irritating)

您可以通过在应用程序中使用更多逻辑来规避最后3个方案,该逻辑将要发送到服务器的消息ID排队,并仅在服务器成功响应时将其删除。

You can circumvent the last 3 scenarios by having even more logic in your app that queues the message id's that are to be sent to the server and removes it only when the server responds successfully.

所以你看,太多工作,服务器端+客户端。

另外,当处理好卷时,服务器端的性能会大幅下降用户以及通过一点点降低应用程序的性能。

So you see, too much work, server-side + client-side.
Plus it's a massive performance degrader on the server-side when dealing with a good volume of users as well as lowering the performance of your app by a wee bit.

这篇关于如何知道推送通知传递状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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