2
I have been trying to notify with Xamarin and Xam.Plugin.Pushnotification. The problem is when I register the plugin. It does not work at the time when the method Up-to-date() is called. In reality what I want is the following: Whenever a field in my BD is updated(Catch) go from 0 to 1, the user who has the App will receive information. I do not know if for that I really need a server, as the firebase or Zure to send these information/notifications. My code is below: Constructor of the mainpage
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 Updated 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;
}
}
On the Xamarin forum, the author of the plugin, told me to boot off mainActivity, but how do I do this, a boot class. Look 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 record means, so I can understand why it does not accept to work together with the service and other things like listview and etc..