Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Xamarin form : How to save data from push notification when app is closed

$
0
0

i am saving my notification in database when i receive, its working fine when app is open, but when i close app from here as shown in image below it doesnt save in database

close app from here
i am really stuck here because it doesnt save in database when my app is close. Here is my code for save in database when i recieve notification.

 protected override void OnStart()
        {
 CrossFirebasePushNotification.Current.OnNotificationReceived += async (s, p) =>
            {

                    bool isread = false;
                    System.Diagnostics.Debug.WriteLine("Received");
                    if (p.Data["open_page"].ToString() == "NewAppointment")
                    {
                        Xamarin.Forms.Device.BeginInvokeOnMainThread(async () =>
                        {

                            await notification.InsertNotificationAppointmentDate(notify, p.Data["title"].ToString(), p.Data["body"].ToString(), isread, p.Data["open_page"].ToString(), Convert.ToDateTime(p.Data["appointmentDate"]));

                        });

                    }
 };

}

i just need to know where i have to put this code to run and save data in database when app is totally close.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>