Azure / azure-notificationhubs-android

Android SDK and Samples for Azure Notification Hubs
Apache License 2.0
33 stars 63 forks source link

onPushNotificationReceived not getting called when Android App is in Background/Terminated State #247

Open himu243 opened 2 years ago

himu243 commented 2 years ago

Describe the bug

When Android App is in Foreground State, onPushNotificationReceived listener is getting invoked having the notification data. When in Background or Terminated State, Notification does get received but onPushNotificationReceived listener is not getting invoked neither automatically nor when I tap on the notification. I'm sending the push from Azure Portal.

{ "notification":{ "title":"Notification Hub Test Notification", "body":"This is a sample notification delivered by Azure Notification Hubs." }, "data":{ "property1":"value1", "property2":53 }, "priority": "high" }

I'm following Tutorial: Send push notifications to Android devices using Firebase SDK version 1.0.0-preview1 (Current SDK) tutorial. https://docs.microsoft.com/en-us/azure/notification-hubs/android-sdk

Is there something else which i need to do apart from the mentioned steps in the above link?

Exception or Stack Trace Add the exception log and stack trace if available

To Reproduce Steps to reproduce the behavior:

Code Snippet Add the code snippet that causes the issue.

Expected behavior It is expected onPushNotificationReceived is triggered in Background/Terminated State of Android app when it receive notification.

Screenshots

NotificationListner AndroidManifest MainActivity

Setup (please complete the following information):

aziztitu commented 7 months ago

@himu243 What version of the SDK are you using?

Also, you mentioned: "When in Background or Terminated State, Notification does get received but onPushNotificationReceived listener is not getting invoked neither automatically nor when I tap on the notification",

If the onPushNotificationReceived is never getting invoked, how are you confirming that the Notification does get received?