0
私はトースト(バナー)通知を表示しようとします。Xamarin.Forms - トースト(バナー) - アラート - iOSとAndroidの背景で
バックグラウンドフェッチとプッシュ通知を確認しました。私はまた、フォアグラウンドでアプリがプッシュ通知を受け取った。
しかし、ときに、背景で私のアプリは - 私は数える私のバッジを変更する方法を見て - 私はこれは私のコードで通知
が表示されない:
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication (new App());
if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
var pushSettings = UIUserNotificationSettings.GetSettingsForTypes (
UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
new NSSet());
UIApplication.SharedApplication.RegisterUserNotificationSettings (pushSettings);
UIApplication.SharedApplication.RegisterForRemoteNotifications();
} else {
UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
UIApplication.SharedApplication.RegisterForRemoteNotificationTypes (notificationTypes);
}
return base.FinishedLaunching (app, options);
}
と
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
{
NSDictionary dic = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary;
var test = (dic[new NSString("test")] as NSString).ToString();
var alert = new UIAlertView ("Test title", "This is message", null, "Ok", "Button");
alert.Clicked += (object sender, UIButtonEventArgs e) => {Console.WriteLine(e.ButtonIndex);};
alert.Show();
}
だから私は言う - 前景ではすべて素晴らしい作品が、バックグラウンドで私はバッジの新しいカウントを参照してください。
また、私はこのプラグインを見つける:
https://components.xamarin.com/view/alert-center
しかし、私は、プラグインなしでそれを記述する方法を理解したいです。
ありがとうございます。