使用客户端读取 APNS 有效负载

发布于 2024-08-07 03:43:09 字数 156 浏览 3 评论 0原文

我想知道发送 APNS 通知时客户端上的应用程序是否能够读取有效负载中的数据?

例如,如果 APNS 通知显示“Hello world!”,并且用户单击“查看”转到应用程序,则应用程序是否可以通过某种方式看到 APNS 通知显示“Hello world!”。

谢谢。

I was wondering if it is possible for the app on the client to be able to read the data in the payload when an APNS notification is sent?

For example, if the APNS notification said "Hello world!", and the user clicked 'View' to go to the app, would there be a way for the app to see that the APNS notification said "Hello world!".

Thanks.

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

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

发布评论

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

评论(1

冧九 2024-08-14 03:43:09

APNS 通知与特定令牌绑定,该令牌与单个手机上的特定应用程序关联。当通知到达时,iPhone OS 会向用户显示警报、播放声音(如果指定)并设置应用程序徽章(如果有)。

如果应用程序正在运行并且屏幕未处于休眠状态,则应用程序将运行并移交有效负载 JSON 数据包。如果应用程序正在运行并且屏幕是暗的,则会向用户显示警报,并通过一个按钮解锁屏幕,然后将有效负载交给应用程序。如果应用程序未运行,用户可以选择“查看/取消”。如果他们点击“查看”,应用程序就会运行并移交有效负载 JSON。

正如您所看到的,在所有这些情况下,包含通知警报、声音、徽章以及您发送的任何其他额外位的 JSON 数据包都会移交给应用程序。该文档向您展示了如何检索 JSON 数据包。如何处理它取决于您。

如果您正在考虑某个应用程序会看到负载流向另一个应用程序,那么答案是否定的。通知与特定应用程序签名相关联。

APNS notifications are tied to a specific token which is associated with a specific app on a single phone. When the notification arrives, iPhone OS shows the user the alert, plays the sound (if specified), and sets the application badge (if any).

If the app is running and the screen isn't asleep the app is run and the payload JSON packet is handed over. If the app is running and the screen is dark, the user is shown the alert with a single button to unlock the screen then the app is handed the payload. If the app is NOT running the user is given a View/Cancel choice. If they tap View, the app is run and the payload JSON is handed over.

As you can see, in all these cases the JSON packet containing the notification alert, sound, badge, and any other extra bits you send is handed over to the application. The docs show you how to retrieve the JSON packet. It's up to you what to do with it.

If you're thinking of an app seeing the payload headed for another app, then the answer is no. Notifications are tied to specific apps signatures.

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