三星设备上由我的应用程序的后台通知引起的频繁崩溃消息



在我的 Xamarin 应用中,我实现了接收每 30 分钟发送一次的静默后台通知的代码。除了在新的三星设备(Galaxy S7,S10等(上,应用程序会收到第一个通知并对其进行处理,但是第二个通知和在上一个通知后半小时发送的其他通知被设备忽略,并在设备上显示一条消息,指出应用程序正在耗尽电池电量并且经常崩溃。

通过检查日志,我可以看到接收传入通知的函数正在为第一个通知运行,但没有为其他传入通知运行,这意味着问题不在于代码本身。

有谁知道问题是由什么引起的?

下面我简要介绍了接收通知的函数:

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;
}
}

应用崩溃的时间点以及用于通知的服务类型。下面提供了一些可能对您有所帮助的链接。 1. https://forums.xamarin.com/discussion/92877/android-app-crashes-after-receiving-push-notification 2. https://github.com/xamarin/Xamarin.Forms/issues/5339 3. Xamarin通知安卓崩溃

最新更新