Frontend Framework: Ionic Angular 5, Capacitor 5
Backend Framework: Spring Boot 2.7
Purpose: I aim to implement different sounds for various types of push notifications based on channels.
When sending push notifications based on channel ID in Android using Postman, it works fine when including the channel ID in the notification payload. However, I’m unsure how to handle this in a Spring Boot application as we don’t have any other documentation to refer to.
Below is the JSON for the push notification sent via Postman:
https://fcm.googleapis.com/fcm/send
{
"to": "asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfuP",
"notification": {
"body": "This issue has been fixed by Contributor.",
"title": "Stack over flow Notification",
"android_channel_id": "channel_id", //above android 11
"channel_id":"channel_id"
},
"data":{}
}
Below code is given for push notificiaton sent via spring boot(backend):
Notification notification2 = Notification.builder()
.setTitle("Stack over flow Notification")
.setBody("This issue has been fixed by Contributor.")
.build();
Message message = Message.builder()
.putData("subject", "Stack over flow Notification")
.putData("body", "This issue has been fixed by Contributor.")
.putData("redirectUrl", "/stack_overflow_page")
.setNotification(notificaitonPayload)
.setToken("easdfasdfasdfasdfasfasdfasfdasdfasfdasdf7C")
.build();
Also consider this information i have found channel_id in AndroidNotification but i not know how to integrate with the notificiaton payload. But android_channel_id is not found in AndroidNotification source code class only found channel_id.
Below Sample code for AndroidNotification:
AndroidNotification not = AndroidNotification.builder().setChannelId("fcm_channel").build();
When sending through Postman, it worked in the notification payload but did not work for the data payload. For Spring Boot, I was unable to set the channel ID in the notification payload, but I was able to set it in the data payload, although it did not work as intended.
I want to send different push notifications based on the channel ID for different sounds in the notification payload from Spring Boot application to android.