0
我想在用戶點擊Notification
時打開xaml
頁面。我已經搜索過,但無法找到適合這種情況的體面樣本。 順便說一句,我正在使用FCM
與舊GCM
integration.How我可以在android中實現這一點?xamarin表單中的通知點擊事件
我想在用戶點擊Notification
時打開xaml
頁面。我已經搜索過,但無法找到適合這種情況的體面樣本。 順便說一句,我正在使用FCM
與舊GCM
integration.How我可以在android中實現這一點?xamarin表單中的通知點擊事件
我想在用戶點擊通知時打開一個xaml頁面。
當您收到Notification
從FCM
,你可以在Notification
添加PendingIntent
來實現這個功能,這將允許用戶打開的應用程序。像這樣的代碼:
void SendNotification(string messageBody)
{
var intent = new Intent(this, typeof(MainActivity));
intent.AddFlags(ActivityFlags.ClearTop);
var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);
var notificationBuilder = new Notification.Builder(this)
.SetSmallIcon(Resource.Drawable.ic_stat_ic_notification)
.SetContentTitle("FCM Message")
.SetContentText(messageBody)
.SetAutoCancel(true)
.SetContentIntent(pendingIntent);
var notificationManager = NotificationManager.FromContext(this);
notificationManager.Notify(0, notificationBuilder.Build());
}
謝謝,我已經這樣做了,但我的問題是我想打開一個不同的xaml pages.Your建議只打開應用程序,我的意思是主頁。 – slayer35