Xamarin pushnotification OnMeasageRecieved event is not triggering in background and killed mode.

Aswathy 41 Reputation points
2023-01-22T14:45:20.0166667+00:00

I have a Xamarin application and want to navigate to different pages when the user taps on the push notification Using azure notification hubs to sent notification.But in android this is not working while the app is in background and on killed mode. Notification is coming but the OnMessageReceived event is not triggering. Please help me on this.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,296 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,299 questions
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 36,061 Reputation points Microsoft Vendor
    2023-01-23T05:28:35.5133333+00:00

    Hello,

    But in android this is not working while the app is in background and on killed mode.

    This should be due to Android's memory management mechanism ending your program in the background.

    For the keepalive mechanism of push notifications, you can use the foreground service to increase the priority of the program in the background to prevent it from being cleaned up.

    Please refer to this documentation: Foreground Services.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our [documentation][1] to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful