I'm trying to make notifications with xamarin and the Xam.Plugin.PushNotification plugin. The problem is when I register the plugin. It does not work, by the time the UpdateData () method is called. Actually what I want is this: Whenever a field in my DB is updated ( FlagLiberacao ) from 0 to 1, the user who has the App will receive information. I do not know if I really need a server, such as firebase or azure to send these information / notifications . My code below: Mainpage builder
public MainPage()
{
InitializeComponent();
try
{
dataService = new DataService();
AtualizaDados();
}
catch(Exception ex)
{
string erro = ex.Message;
}
}
The OnAppearing method
protected override void OnAppearing()
{
base.OnAppearing();
try
{
lblTipoVenda.Text = "Tipo de Venda:";
lblVencimento.Text = "Vencimento:";
lblJuros.Text = "Juros:";
lblEntrada.Text = "Entrada:";
lblAcrescimo.Text = "Acréscimo:";
lblDesconto.Text = "Desconto:";
btnItens.IsEnabled = false;
AtualizaDados();
}
catch (Exception ex)
{
string erro = ex.Message;
}
}
The UpdateData method
private async void AtualizaDados()
{
try
{
lib = await dataService.GetLiberaAsync();
listaLibera.ItemsSource = lib.OrderBy(item => item.Cliente).ToList();
}
catch(Exception ex)
{
string erro = ex.Message;
}
}
The CrossNotificationListener class created in the android project
public class CrossPushNotificationListener : IPushNotificationListener
{
public CrossPushNotificationListener()
{
}
public void OnError(string message, DeviceType deviceType)
{
}
public void OnMessage(JObject values, DeviceType deviceType)
{
}
public void OnRegistered(string token, DeviceType deviceType)
{
}
public void OnUnregistered(DeviceType deviceType)
{
}
public bool ShouldShowNotification()
{
return true;
}
}
In the Xamarin forum, the author of the plugin, told me to boot out of mainActivity, but as I do this, a startup class. Here's what he said:
It seems you are initializing in the MainActivity instead of an Application class, if you want it to work when closed then should initialize there instead. Anyways if you are using firebase for both iOS and Android I will recommend you use:
I would like to understand what this registry means, so I can understand why it does not accept working with the service and other things, such as listview and etc.