In my Xamarin app, I have implemented code to receive silent background notifications which is sent every 30 minutes. Everything works fine except on new Samsung devices (Galaxy S7, S10 etc.) the application receives the first notification and processes it, but the second notification and the other ones that is sent half an hour after the previous notification, are ignored by the device and a message is shown on the device saying the application is draining battery and has frequently crashed.
By checking the logs I can see the function which receives the incoming notifications is running for the first notification but is not running for the other incoming ones, which means the problem is not from the code itself.
Anyone knows what the problem is caused by?
Below I have given a short view of my function that receives the notification:
public async override void OnMessageReceived(RemoteMessage message)
{
Log("This is logged only first time when app is in background");
//if the message does not contain a type then print out the message only
if (String.IsNullOrEmpty(message.Data["type"]))
{
SendNotification(message.Data["message"], "MyApp");
return;
}
string messageType = message.Data["type"];
switch (messageType)
{
case "CheckUserGPS":
//checks the users gps and updates the user in server
.....
break;
}
}