我应该在收到有效载荷后更新我的应用吗或者我应该通过允许它自己下载来更新它? [英] Should I update my app upon receiving payload? Or I should always update it by allowing it to download for itself?

查看:127
本文介绍了我应该在收到有效载荷后更新我的应用吗或者我应该通过允许它自己下载来更新它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您的iPhone收到WhatsApp / Telegram推送通知时,例如

When your iPhone receives a WhatsApp/Telegram push notification e.g.

wife:
"buy pizza"

问题1:该应用是否必须下载/接收该本身。那个手机弹出的横幅必须自己下载+我的Whatsapp / Telegram必须自己再次下载?

Question1: Is it that the app has to download/receive that itself. That is the banner that pops up on the phone has to download for itself + my Whatsapp/Telegram has to download again for itself?

我的朋友回复:


推送通知可以将消息作为有效负载。你的应用程序可以
提取并动态插入到对话中而不需要
发出额外请求 - 我之前已经这样做了。让它觉得
更加快捷。缺点是您无法保证推送
将以正确的顺序(或根本没有)到达。

Push notifications can have the message as a payload. Your app could extract that and dynamically insert into the conversation without making an additional request - I've done that before. Makes it feel much snappier. The downside is that you're not guaranteed that pushes will arrive in the correct order (or at all).

但我不相信,从语义的角度来看,推送通知本身不应该更新你的应用程序。如果他们这样做,那将是一种滥用......他们应该通知您的应用更新,然后允许您通过下载任何已提供的新内容自行进行更新。

But I wasn't convinced, from a semantic point of view, push notifications shouldn't really update your app themselves. It would be an abuse if they do...They should only notify your app of an update and then allow you to do the update yourself through you downloading whatever new content that has been made available.

因此,要查看顶级公司及其应用是否正在应用我的朋友建议我使用3个应用(Gmail,WhatsApp,Telegram)进行了一些实验:

So to see if the top companies and their apps are applying what my friend suggested I did a little experiment with 3 apps (Gmail, WhatsApp, Telegram):

然后我有人给我发了一条消息/电子邮件:
这是我的结果:

Then I had someone send me a message/email: Here are my results:

电报::我收到提醒(发件人+第一行)。但是一旦我打开应用程序(或点击通知),它就没有我的新消息或任何东西。

Telegram:: I get an alert (that has the sender + first line). But once I open the app (or tap on the notification), it doesn’t have my new message or anything.

但是,如果允许Telegram访问互联网......它会在后台下载消息......即如果我按照序列:我是无线网络或没有互联网限制的手机数据 - >收到通知 - >完全关闭互联网,然后转到应用程序:我会在那里看到完整的消息/正文。

However, if Telegram is allowed to have access to internet…it downloads the messages in the background…that is if I follow this sequence: I’m wifi or on cellular data with no internet restriction --> receive a notification --> turn internet completely off but then go to app: I will see the complete message/body there.

Gmail:我收到提醒(主题/发件人/正文预览)但是一旦我打开应用程序,它就没有我的新消息或任何内容。

Gmail: I get an alert (that has a preview of subject/sender/body) But once I open the app, it doesn’t have my new message or anything.

如果允许Gmail应用访问互联网...那么与Telegram相反:只有在打开应用程序本身之前,它才会下载/更新Gmail中的电子邮件。我猜Gmail没有内容可用设置为 1 但Telegram将其设置为 1

If the Gmail app is allowed to have access to internet…then contrary to Telegram: without only until opening the app itself it will download/update emails in Gmail. I’m guessing Gmail doesn’t have content-available set to 1 but Telegram has it set to 1

WhatsApp:我什么都没得到。

收到通知后没有互动...只有当应用程序正在下载本身

NO interaction happens upon receiving the notification…It only happens if app is downloading itself.

我的结论是:

收到通知后没有发生任何互动......只有当应用程序正在下载本身时才会发生这种情况。

NO interaction happens upon receiving the notification…It only happens if app is downloading itself independent from the payload arrival.

Gmail和Telegram正在进行冗余下载,基本上不够智能,我的朋友建议或者没有收到电子邮件/消息的风险太大在安全方面最好:thinking_face:

Gmail and Telegram are doing a redundant download and basically are't smart enough to what my friend suggested OR that the risk of not receiving an email/message is too much and it’s better to be on the safe side :thinking_face:

问题2:这个结论是否正确?

推荐答案

首先,下载有效载荷通常不是问题。我想象有效载荷通常非常小(对于短文本消息,可能<1Kb)。实际上,常规远程有效负载的最大大小为4KB(VoIP通知为5KB)。请参阅 创建远程通知有效负载

First, downloading the payload usually isn't a problem. I'd imagine that the payload is usually very small (probably <1Kb for short text messages). In fact, the maximum size for a regular remote payload is 4KB (5KB for VoIP notifications). See Creating the Remote Notification Payload.

其次,很难让您的应用访问任何远程通知数据。唯一可行的方法是通过静默通知,不建议用于简单的文本通知。静音通知会唤醒您的应用,并在再次关闭之前为其提供30秒的时间在后台执行操作。您可能会发送远程静默通知,导致您的应用程序根据该远程通知手动触发常规本地通知(或同时发送静默和常规远程通知),但同样不推荐使用静默通知:

Second, it is hard to have your app access any remote notification data. The only way that is possible is through a Silent Notification, which is not recommended for simple text notifications. A Silent Notification wakes up your app and gives it 30 seconds to perform actions in the background before it is shut down again. You could potentially send a remote Silent Notification that causes your app to manually trigger a regular, local notification based on that remote one (or send both a silent and regular remote notification), but again, such use of Silent Notifications is not recommended:


无声通知并不意味着让您的应用程序在后台保持清醒状态,也不是用于高优先级更新。 APN将无声通知视为低优先级,如果总数过多,可能会完全限制其传递。实际限制是动态的,可以根据条件进行更改,但尝试不要每小时发送多个通知。

Silent notifications are not meant as a way to keep your app awake in the background, nor are they meant for high priority updates. APNs treats silent notifications as low priority and may throttle their delivery altogether if the total number becomes excessive. The actual limits are dynamic and can change based on conditions, but try not to send more than a few notifications per hour.

参见< A HREF = https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW8 相对= nofollow noreferrer > 配置无声通知 以获取更多信息。

See Configuring a Silent Notification for more info.

应用可以收到远程通知的另一种可能方式描述于 修改远程通知的有效负载 。您只需保存通知并选择不修改它们。

Another possible way that apps could "download" remote notifications as they are received is described in Modifying the Payload of a Remote Notification. You could simply save the notifications and choose not to modify them.

没有通用的是/否答案适用于所有应用程序的任何问题。相反,应用可以通过多种不同的方式接收远程通知并处理其数据。

There is no universal yes/no answer that works for all apps to either of your questions. Instead, there are a number of different ways that apps could receive remote notifications and process their data.

编辑:您还应该实施 application(_:didReceiveRemoteNotification:fetchCompletionHandler:) 并从通知的用户信息中检索/保存数据,以便在您的应用中更快地获得数据。但是,不保证调用该方法。所以你可以/应该实现它,但更重要的是,让你的应用程序检查你自己的服务器上的新数据,这样就不会遗漏任何内容。

EDIT: You should also implement application(_:didReceiveRemoteNotification:fetchCompletionHandler:) and retrieve/save data from the user info of the notification so that the data is available faster in your app. However, that method is not guaranteed to be called. So you could/should implement it, but more importantly, have your app check for new data from your own server so that nothing is missed.

这篇关于我应该在收到有效载荷后更新我的应用吗或者我应该通过允许它自己下载来更新它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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