私はApplication.Current.Propertiesを使用してデータを保存することができ、[キー]どのようにアンドロイドGcmServiceからフォームのプロパティをxamarinアクセス
しかし、どのようにリモート通知が到着したときにどのように私はAndroidのからこのデータを読み取ることができますか?
アプリケーションが閉じられていて、「現在の」Xamarin Formアプリケーションがない場合、このデータをどのように読み書きできますか?
[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());
}
このGcmServiceは名前のとおり、サービスであり、アプリケーションの状態に関係なくOnMessageメソッドが実行されます。このように考えると意味がありません。このサービスの動作について検討していますか? –
いいえ、私の質問は非常に明確です。 Xamarinフォームのプロパティでデータにアクセスするにはどうしたらいいですか?私は現在のアプリケーションがないと言うので、obviosly thatsではない方法です。私の質問は、そのデータにアクセスする別の方法です。多分パスファイルや別のライブラリ –