android - 由于我的应用程序的后台通知导致三星设备上经常崩溃的消息
问题描述
在我的 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 通知 Android 崩溃
推荐阅读
- c# - 在 XElement 中使用“for”循环
- javascript - 检查所有/总和值 - 如何将跨度放在输入中
- java - 在 Java 属性文件中使用值作为键
- java - 将具有负值的 byte[] 转换为 String
- python - 从 oracle (plsql) 运行 .py
- python - ValueError:Series 的真值不明确。使用 a.empty、a.bool()、a.item()、a.any() 或 a.all():返回具有空值的列
- mongodb - Combine MongoDb clients: pyMongo and MongoEngine
- java - 来自 Lombok 的`@Setter` 的用法
- c# - 如何使用 Microsoft.Management.Infrastructure (MMI) 而不是 System.Management 进行本地 WMI 查询
- php - 复选框使选择输入使用 jquery 所需的 foreach