gpt4 book ai didi

ios - 当应用程序不在前台时从 iOS 应用程序向上游发送 gcm + 用于上传 APNs 证书的 gcm API

转载 作者:可可西里 更新时间:2023-11-01 02:03:59 25 4
gpt4 key购买 nike

我有两个关于使用 gcm 库的 APNs 推送通知 的问题。

  1. gcmfcm 是否有用于上传 APNs 证书public api?我需要自动而不是手动执行此操作。

  2. iOS 应用 中使用gcm 库发送上游 似乎只在应用处于前台时有效。这是对的吗?即使应用程序未打开或处于后台,是否有任何解决方法可以向上游发送?我想使用 gcm upstream 向我的服务器发送通知 click 事件,最好立即执行。

    我知道我可以保存这个点击事件并在应用激活时发送它,但用户可能很长时间没有打开应用。

最佳答案

1. Does gcm or fcm have a public api for uploading APNs certificates?

目前没有用于上传 APNs 证书的公共(public) API。对于 FCM(和任何新项目),它只能通过 Firebase Console 完成.此外,似乎现在在证书上使用 APNs 身份验证 key 似乎更方便 (APNs Overview)。

2. It seems that sending upstream using gcm library in an iOS app, only works when app is in foreground. Is it correct?

是的。上游消息传递必须有连接才能工作。

Is there any workaround to send upstream even when app is not open or is in background?

据我所知,没有。如 FCM doc 中所述(强调我的):

To send messages upstream to the server, an iOS client app composes a message, connects to FCM, and calls sendMessage.

To connect, set the shouldEstablishDirectChannel flag to YES in the AppDelegate. FCM manages the connection, closing it when your app goes into the background and reopening it whenever the app is foregrounded.

...

The FCM client library caches the message on the client app and sends it when the client has an active server connection. On receiving the message, the FCM connection server sends it to the app server.

它提到 FCM 管理连接,但是 AFAICT,iOS 设备存在此限制,限制应用程序在后台/关闭时保持运行服务(参见 answer)。如果无法建立连接,上游消息传递将不起作用。

作为一般做法,通过 FCM 传递的数据应尽可能改善用户体验,并且不传递任何应用关键数据。

I am aware that I can save this click event and send it when app become active, but it is possible that user does not open the app for a long time.

这是可能的。但用户也不太可能在推送通知显示后不立即点击它。在这种情况下,通常的操作是让用户在连接仍处于打开状态时立即单击通知。

关于ios - 当应用程序不在前台时从 iOS 应用程序向上游发送 gcm + 用于上传 APNs 证书的 gcm API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44604526/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com