Azure / Azure/azure-notificationhubs-java-backend
Unable to successfully send android notification
- 主要言語
- Java
- スター
- 35
- フォーク
- 52
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
We are trying to send a push notification on android device using GCM/FCM with the latest Notification-Hubs-java-sdk version (1.0.4).
We wrote the same code in dotnet and we can successully send a notification. Using the java sdk we see that the notification are received on notification hub but they never pass to successfull status on dashboard.
Watching the situation on firebase with the java code none of the notification are delivered to the account. Instead, the same hub, used by dotnet delivered notification successfully.
Working Dotnet code
```c#
String TOKEN = "XXXXX";
String CONNECTION_STRING = "Endpoint=sb://joinon-notificationhub-dev.servicebus.windows.net/;SharedAccessKeyName=joinon-notificationhub-dev;SharedAccessKey=YYYYY";
String HUB_NAME = "joinon-notificationhub-dev";
String BODY = "{\"data\":{\"title\": \"maco: TESTME\",\"body\" : \"Nessuna perdita d’acqua nella stanza sensori.\", \"icon\": \"notification/water_off\"}, \"notification\":{\"title\": \"maco: Nessun allarme perdita acqua rilevato\",\"body\" : \"Nessuna perdita d’acqua nella stanza sensori.\"}}";
String installationId = "installationIdTest";
NotificationHubClient _notificationHub = NotificationHubClient.CreateClientFromConnectionString(CONNECTION_STRING, HUB_NAME);
Installation installation = new Installation();
installation.InstallationId = installationId;
installation.PushChannel = TOKEN;
installation.Platform = NotificationPlatform.Fcm;
await _notificationHub.CreateOrUpdateInstallationAsync(installation);
Task outconme = _notificationHub.SendFcmNativeNotificationAsync(BODY, "$InstallationId:{" + installationId + "}", CancellationToken.None);
await _notificationHub.DeleteInstallationAsync(installation.InstallationId);
```
NOT Working Java code
```java
String TOKEN = "XXXX";
String CONNECTION_STRING = "Endpoint=sb://joinon-notificationhub-dev.servicebus.windows.net/;SharedAccessKeyName=joinon-notificationhub-dev;SharedAccessKey=YYYYY";
String HUB_NAME = "joinon-notificationhub-dev";
String BODY = "{\"data\":{\"title\": \"maco: TESTME\",\"body\" : \"Nessuna perdita d’acqua nella stanza sensori.\", \"icon\": \"notification/water_off\"}, \"notification\":{\"title\": \"maco: Nessun allarme perdita acqua rilevato\",\"body\" : \"Nessuna perdita d’acqua nella stanza sensori.\"}}";
NotificationHub notificationHub = new NotificationHub(CONNECTION_STRING, HUB_NAME);
String installationId = "installationIdTest";
Installation installation = new Installation(UUID.randomUUID().toString(), NotificationPlatform.Gcm, TOKEN);
notificationHub.createOrUpdateInstallation(installation);
Notification n = Notification.createFcmNotification(BODY);
NotificationOutcome outcome = notificationHub.sendNotification(n, "$InstallationId:{" + installationId + "}");
notificationHub.deleteInstallation(installationId);
```
コントリビューションガイド
調査の方向性
まず Java と .NET のスニペットを比較し、特に各フローで使用されている installation ID、プラットフォーム、通知セレクターを確認します。Java SDK の呼び出しを追跡して installation の作成、送信、削除を行い、その後、動作する .NET の例を基準に結果と配信動作を検証します。Java のパスから登録済みの Android デバイスに通知が正常に送信されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- azure, java
- 領域
- api, backend, mobile
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100