首页 > 解决方案 > 由于我的应用程序的后台通知导致三星设备上经常崩溃的消息

问题描述

在我的 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;
            }

    }

标签: androidxamarinpush-notificationsamsung-mobile

解决方案


您的应用程序在什么时候崩溃以及您用于通知的服务类型。下面给出的一些链接可能会对您有所帮助。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 崩溃


推荐阅读