Not receving the notification when App is in background

Chandrika K 1 Reputation point
2020-07-17T13:15:26.103+00:00

We are implementing the Push notification in Android using Azure Notification Hub v1.0.0-preview1 SDK.
we are not able to receive the notification when App is in Background/Not launched

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.
301 questions
{count} votes

2 answers

Sort by: Most helpful
  1. sadomovalex 3,631 Reputation points
    2020-08-19T15:51:41.617+00:00

    what payload do you use in push notification body? Try to send the following push notification from Notification Hub itself using Test button:

    {
       "notification": {
          "title":"Title1",
          "body":"Body1",
          "priority":"10",
          "sound":"default",
          "time_to_live":"600"
       },
       "data": {
          "title":"Title2",
          "body":"Body2",
          "url":"https://example.com"
       }
    }
    
    0 comments No comments

  2. Aleksandrs Vorobjovs 1 Reputation point
    2021-02-26T13:35:48.697+00:00

    Hi,

    I have the same issue.
    I use the Xamarin.Azure.NotificationHubs.Android version 1.1.4.1. in my Xamarin.Android project. I configured the project as it is described on this page
    https://learn.microsoft.com/en-us/azure/notification-hubs/xamarin-notification-hubs-push-notifications-android-gcm

    It works fine when the Android app is in the foreground. In this case, when the notification is sent to the app, the NotificationListener is raised, I can handle it and show the notification to a user.

    But, ff the app is in the background or is closed, then a notification appears in the Android notification area (in the system tray). And, in this case, when the user taps the notification in the notification area, then the app opens but the NotificationListener is not raised. As a result, I cannot handle it and show the notification to the user in the app.

    Can you tell me what is wrong with it? How to fix it?
    Please help me ASAP! Thank you in advance!

    Best Regard,
    Aleksandrs

    0 comments No comments