Thank you. I will send you an email shortly.
Notification Hubs :FCM Message
Hi
I've successfully sent push notification to the android device using the method
"NotificationHubClient.SendFcmNativeNotificationAsync(string jsonPayload, string tagExpression)" from Asp.net core backend, but not able to set some of the fields defined 'RemoteMessage' object received on android app
override fun onMessageReceived(remoteMessage: RemoteMessage)
{
var myData = remoteMessage.data.toString()
var messageType = remoteMessage.messageType // always null not sure why?
var notification = remoteMessage?.notification
}
I would like to know if there are any predefined data classes in the Microsoft.Azure.NotificationHubs.net library that assist in formatting the FCM message payload as described in the link concept-options
Any suggestions are greatly appreciated.
2 additional answers
Sort by: Most helpful
-
ENRICO FACCHINETTI 6 Reputation points
2020-09-26T17:53:24.347+00:00 Hi, I just found myself in the exactly same situation clearly described by Rayaprol. But I didn't find any replay.
I need to define from back-end, some info concerning the type of notification to show, like: ChannelId, Title, Priority, Sound etc.
I would do it through the Azure Notifications Hub library, but in the following code (the method onMessageReceived() fired on client side to the app) object RemoteMessage.Notification is always null.@Override
public void onMessageReceived(RemoteMessage remoteMessage) {RemoteMessage.Notification notification = remoteMessage.getNotification(); // Check if message contains a notification payload. if (notification != null) { String channelId = notification.getChannelId(); String title = notification.getTitle(); String message = notification.getBody(); int priority = notification.getNotificationPriority();
....
The only way I found to fetch the message I need is launching the following peace of code I found in the online documentation:
message = remoteMessage.getData().values().iterator().next();
Is there anybody knowing how to get also the other info about the notification (title, priority etc)?
Thanks.
E. -
brtrach-MSFT 16,586 Reputation points Microsoft Employee
2020-08-01T08:44:17.477+00:00 @Chandra Mohan , We were unable to find content that we can publicly share. We would like to assist you further through a free support ticket. If you still require assistance, please email us at azcommunity@microsoft.com with your Azure subscription ID and the URL of this post. We look forward to your reply.