与向服务器发出的普通请求相比,原始通知有什么优势?

发布于 2025-01-03 20:45:50 字数 128 浏览 2 评论 0原文

我知道当您的应用程序处于非活动状态时,平铺通知和 Toast 通知会派上用场,但是原始通知相对于下一行的优势是什么?

WebClient( ).DownloadStringAsync( );

I know where Tile Notification and Toast Notification come in handy, when your app is inactive, but what is the advantage of Raw Notifications over the next line?

WebClient( ).DownloadStringAsync( );

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

楠木可依 2025-01-10 20:45:50

原始通知允许您在应用程序运行时将自定义数据按需推送到应用程序。 WebClient.DownloadStringAsync 允许您从服务器提取数据。

Raw notifications allow you to push custom data on-demand to your application while it's running. WebClient.DownloadStringAsync allows you to pull data from a server.

陌伤浅笑 2025-01-10 20:45:50

在很多情况下,原始通知可能最好与拉取请求一起使用。我倾向于纯粹使用通知来告诉正在运行的客户端 - 这可能是从新消息已到达服务器端(在这种情况下您可能希望在通知中发送消息)到“整个消息”的任何内容。服务器上的数据集已更新,您最好尽可能地过来并获取最新的更改”。

如前所述,您可以使用原始通知来发送所有必需的信息(如果它足够小),但在其他情况下,您很可能只是告诉应用程序需要给家里打电话以获取一些信息。行动。您的选择必须基于预期的有效负载大小。来自 MSDN

通知的最大大小为 1 KB(标头)和 3 KB(
有效负载。

A raw notification is probably best used alongside a pull request in a lot of cases. I would tend to use a notification purely to tell a running client that - that could be anything from a new message has arrived server-side (in which case you might want to send out the message in the notification) to "The whole of the data set on the server has been updated, you'd better come along when you can and get the latest changes".

As mentioned, you can use the raw notification to send out all the required information if it is small enough, but on other occasions you will most likely just be telling the app that it needs to call home for some action. Your choice would have to be based on the expected size of the payload. From MSDN

The maximum size of a notification is 1 KB for the header and 3 KB for
the payload.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文