Notification Hubs :FCM Message

Chandra Mohan 461 Reputation points
2020-07-28T11:23:48.907+00:00

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.

Azure Notification Hubs
Azure Notification Hubs
An Azure service that is used to send push notifications to all major platforms from the cloud or on-premises environments.
325 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,905 questions
0 comments No comments
{count} vote

Accepted answer
  1. Chandra Mohan 461 Reputation points
    2020-08-04T08:50:53.243+00:00

    Thank you. I will send you an email shortly.


2 additional answers

Sort by: Most helpful
  1. 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.

    1 person found this answer helpful.
    0 comments No comments

  2. 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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.