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

我需要使用通过在线MVC应用程序发送的详细信息更新SQLite数据库,该应用程序将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应用程序发送到已注册电话上的链接用户应用程序的负载的特定详细信息。

我想在应用处于离线/后台状态时调用特定的空白来运行。

最近对服务等的所有控制都是可行的吗?

feidaokuan2 回答:Xamarin Firebase消息在应用程序处于关闭状态时运行Intent

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

本文链接:https://www.f2er.com/3152310.html

大家都在问