firebase / firebase/firebase-admin-java

Android device only receive 1 notification when offline.

未關閉
#812 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Java
星號
620
分支
305
平均合併
3 小時 23 分鐘
30 天內合併 PR
1

描述

My app sends non-collapsible push notification.
When push notification are sent while device is online, everything works fine. Notifications are sent one by one. The problem is that if the device is offline (closed or airplane mode) only the last notification sent is received when the device come back online.

A work around that seems to be popular online is to generate unique collapseKey to force firebase to push notification in separate "collapse group".
I know the limit is only 4 collapse key, but it is enough notifications for the app I'm building.

I've achieved the desired result on IOS by settings my apns-collapse-id to a random UUID for each notifications but now that I'me trying with android it doesn't seems to work.

I uses
Firebase-admin version 9.1.1
```

com.google.firebase
firebase-admin
9.1.1

```
This library uses FCM HTTP v1 endpoint

The collapseKey fields works.
When setting it with this function : `AndroidConfig.builder().setCollapseKey("non_unique_collapse_key").build()`

The notifications are overwritten.

If I set it like this : `AndroidConfig.builder().setCollapseKey(UUID.randomUUID().toString()).build()`

All notification are sent separately.

The problem is that if I put my android to airplane mode, send myself 3 notifications (with 3 different collapse_key)
When I put my device back online, I only receive the last notification sent.

The same cannot be said for IOS.

I set my notification like so :
```
ApnsConfig.builder().putHeader("apns-collapse-id", collapseKey)
.setAps(Aps.builder().setAlert(
ApsAlert.builder().setTitle(title).setBody(notificationContent).build()).build())
.build();
```

and when I put my iphone back online, I receive 3 notifications.

貢獻指南

開啟貢獻指南

研究方向

從 AndroidConfig.builder().setCollapseKey 的使用方式以及 issue 中描述的 Firebase Admin Java SDK 9.1.1 設定開始。讓 Android 裝置處於飛航模式,透過 FCM HTTP v1 端點傳送三個具有不同折疊金鑰的通知來重現,然後將結果與 APNs 設定進行比較。完成標準是確定 Android 的傳遞行為是否符合預期,或確認一個有文件記錄的 SDK 或 FCM 問題。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
android, java
領域
backend, mobile-dev
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
30/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。