Xamarin Firebase消息在应用程序处于关闭状态时运行意图

问题描述 投票:1回答:1

我需要使用在线MVC应用程序发送的详细信息更新SQLite数据库,该MVC应用程序将Firebase数据消息发送到链接到特定用户个人资料的Xamarin应用程序当应用程序处于前台时,我可以使用firebase数据消息中包含的详细信息直接更新数据库。

问题是,我需要在应用程序处于关闭状态时更新数据库,因此当他们打开数据库时,UI和数据状态已经构建好并可供用户使用(无需执行HTTP请求即可任何新信息)

[通过工作,我已经看到必须使用Firebase.Jobdispatcher ...但是我发现它似乎已被弃用。

public override void OnMessageReceived(RemoteMessage message)
{
    base.OnMessageReceived(message);

    //Custom message received
    if (IsApplicationInTheBackground())
    {         
        //The send notification sends the push notification no problem 
        SendNotification(message.GetNotification().Body, message.Data);

        //I wish to add specific code to write to the SQLite here 

    } else
    {
        //Notify within the application using snackbar
        var mA = new MessageAndroid();
        mA.ShortAlert(message.GetNotification().Body);

        var uti = new FindMyDriver();    //Location pin pointing request
        uti.ReturnLocationAsync(message.GetNotification().Body);

    }    
}

在其声明“我希望添加特定代码..的方框中,我想保存有关已从MVC应用程序发送到已注册电话上的链接用户应用程序的负载的特定详细信息。

我想称特定的空白在应用程序处于脱机状态/后台时运行。

最近对服务等的所有控制措施是否可行?

c# firebase xamarin
1个回答
0
投票

上面的大问题是FCM实际上没有触发OnMessageReceived事件。这是由于FCM是作为通知而不是作为数据有效载荷接收的。一旦将有效负载更改为数据,它就能100%工作,从而允许我初始化前台服务并从那里运行。

© www.soinside.com 2019 - 2024. All rights reserved.