简体   繁体   English

如何证明我没有通过Firebase平台或其他方式收到iOS静默通知

[英]How to prove that I'm not receiving iOS silent notification through Firebase platform or otherwise

I'm trying to handle silent notification sent to me from by backend which triggers Firebase services and it (probably?) triggers Apple servers to send the push.我正在尝试处理后端发送给我的静默通知,它会触发 Firebase 服务,它(可能?)会触发 Apple 服务器发送推送。

I've selected Remote notifications and Background fetch in project's Signing & Capabilities:我在项目的 Signing & Capabilities 中选择了 Remote notifications 和 Background fetch: xcode 项目中的远程通知和后台获取设置

The usual notifications tested by Firebase console backend are working fine. Firebase 控制台后端测试的常规通知工作正常。 Yet, while I want to handle the silent notifications (which I cannot send directly on Firebase console) by implementing the然而,虽然我想通过实现来处理静默通知(我不能直接在 Firebase 控制台上发送)

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)

method, I got nothing - the method is not called - while backend developer assures me that the silent push notification has been is sent (at least to Firebase).方法,我什么也没得到——方法没有被调用——而后端开发人员向我保证静默推送通知已经发送(至少发送到 Firebase)。

The piece of code run on the backend to trigger Firebase silent notification looks somehow like this:在后端运行以触发 Firebase 静默通知的代码看起来像这样:

ApnsConfig.builder()
    .setAps(
        Aps.builder()
            .setCategory(pushType.toString())
            .setContentAvailable(true)

I'm testing it while the app is running - since this silent notification is used to update the state of the app when user triggered something on the web just after he/she interacted with the website (by scanning the website QR code).我在应用程序运行时对其进行测试 - 因为当用户在他/她与网站交互后(通过扫描网站二维码)触发 web 上的某些内容时,此静默通知用于更新应用程序的 state。

To debug it I'm trying to intercept all the connections using Charles application - but for now without any success (I'm not able to see even standard push notification being received - which is being shown).为了调试它,我试图拦截所有使用 Charles 应用程序的连接 - 但目前没有任何成功(我什至无法看到收到标准推送通知 - 正在显示)。 Maybe I should be able to see some logs in the Firebase console which I have not found yet?也许我应该能够在 Firebase 控制台中看到一些我尚未找到的日志?

How can I prove (or disprove) that the correct notification to the correct device is not being sent and received?我如何证明(或反驳)没有向正确的设备发送和接收正确的通知?

UPDATE: Using Curl to fire background push is working - while using legacy method of sending the push更新:使用 Curl 触发后台推送正在工作 - 同时使用发送推送的传统方法

curl --location --request POST 'https://fcm.googleapis.com/fcm/send' \

--header 'Authorization: key=HERE_AUTH_KEY' \

--header 'Content-Type: application/json' \

--data-raw '{

    "to" : "HERE_FIREBASE_MESSAGING_IDENTIFIER",

  "content_available": true,

  "apns-priority": 5

}'

Sadly,可悲的是,

Apple platforms do not guarantee the delivery of background notifications. Apple 平台不保证后台通知的传递。

see also here .另请参阅此处 You should however be able to see if a notification was delivered or not by looking at the result of the sendNotification Method in the backend.但是,您应该能够通过在后端查看 sendNotification 方法的结果来查看通知是否已发送。

You could use a Websocket to have the server notify the device that something happened and it should update the UI.您可以使用 Websocket 让服务器通知设备发生了某些事情并且它应该更新 UI。

As it turned out the problem was with the Firebase platform code - actually I was not receiving background pushes.事实证明,问题出在 Firebase 平台代码上——实际上我没有收到后台推送。

On the backend the putHeader("apns-push-type", "background") was needed to send correct silent push.在后端, putHeader("apns-push-type", "background")来发送正确的静默推送。

Here is a whole code used to send silent push through Firebase platform:这是用于通过 Firebase 平台发送静默推送的完整代码:

private fun createSilentApnsConfig(pushType: SilentPushType) =
    ApnsConfig.builder()
        .setAps(
            Aps.builder()
                .setCategory(pushType.toString())
                .setContentAvailable(true)
                .build()
        )
        .putHeader(APNS_PRIORITY, APNS_PRIORITY_FOR_SILENT_PUSH)
        .putHeader(APNS_PUSH_TYPE, APNS_PUSH_TYPE_BACKGROUND)
        .build()

[....]

const val APNS_PRIORITY = "apns-priority"
const val APNS_PRIORITY_FOR_SILENT_PUSH = "5"
const val APNS_PUSH_TYPE = "apns-push-type"
const val APNS_PUSH_TYPE_BACKGROUND = "background"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未收到通过 iOS 应用程序中的 firebase 云功能发送的推送通知,尽管我从消息控制台获取 - Not receiving push notification sent via firebase cloud functions in iOS app though I get the from messaging console Firebase Cloud Messaging 静默推送通知无法正常工作 - Firebase Cloud Messaging Silent Push Notification fail to work 如何通过 Firebase 设置自定义身份验证声明并识别平台 - How to set custom auth claims through Firebase and identify platform Flutter GoRouter 并接收 Firebase 推送通知 - Flutter GoRouter and receiving Firebase Push notification Firebase Android 12 上未收到推送通知 - Firebase Push notification not receiving on Android 12 Firebase 云消息 - 手机收不到推送通知 - Firebase Cloud Messaging - Mobile not receiving push notification 如何禁止在 kotlin 的特定活动中接收通知? - How can I disable receiving notification in a specific activity in kotlin? 如何通过firebase云消息发送定时通知到flutter app - how to send scheduled notification to flutter app through firebase cloud messaging 如何在 ios 中设置徽章计数 firebase 推送通知? - How to setup badge count firebase push notification in ios? iOS 应用程序未收到 Firebase 通知 - iOS app not receiving Firebase notifications
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM