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
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.