I can store data using Application.Current.Properties [key]
But how how can I read this data from Android when a remote notification arrives ?
If the aplication is closed and there is no "current" Xamarin Form Aplication how can I read/write this data?
[Service]
public class GcmService : GcmServiceBase
{
public static string RegistrationID { get; private set; }
public GcmService()
: base(PushHandlerBroadcastReceiver.SENDER_IDS) { }
protected override void OnRegistered(Context context, string registrationId)
{
Log.Verbose("PushHandlerBroadcastReceiver", "GCM Registered: " + registrationId);
RegistrationID = registrationId;
}
protected override void OnMessage(Context context, Intent intent)
{
var msg = new StringBuilder();
if (intent != null && intent.Extras != null)
{
foreach (var key in intent.Extras.KeySet())
msg.AppendLine(key + "=" + intent.Extras.Get(key).ToString());
}
string textoNotificacion = intent.Extras.GetString("gcm.notification.body");
var nombre = "Alumno - ";
if (!string.IsNullOrEmpty(textoNotificacion))
{
//***************************************** //
var idEstatus = "0";
var textoEstatus = "Cambio de Estatus";
if (textoNotificacion.Length > 2)
{
idEstatus = textoNotificacion.Substring(0, 1);
textoEstatus = textoNotificacion.Substring(1);
}
try
{
var app = App.Current;
if (app == null)
{
Read and Save data in xamarin form properties here!!!
}
else
{
var mp = (MainPage)app.MainPage;
nombre = mp.getNombre() + " - ";
mp.actualizarEstatus(idEstatus, textoEstatus);
}
}
catch(Exception e)
{
createNotification("Aplication ",e.Message);
}
createNotification("Aplication ", nombre +textoEstatus);
return;
}
createNotification("Unknown message details", msg.ToString());
}