Azure / Azure/azure-notificationhubs-java-backend
Unable to successfully send android notification
- Ngôn ngữ chính
- Java
- Star
- 35
- Fork
- 52
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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);
```
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách so sánh các đoạn mã Java và .NET, đặc biệt là installation ID, nền tảng và bộ chọn thông báo được sử dụng trong từng luồng. Theo dõi các lệnh gọi Java SDK để tạo, gửi và xóa installation, sau đó kiểm tra kết quả và hành vi phân phối dựa trên ví dụ .NET đang hoạt động. Hoàn tất khi đường dẫn Java gửi thông báo thành công đến thiết bị Android đã đăng ký.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- azure, java
- Lĩnh vực
- api, backend, mobile
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100