diff --git a/8.0/WebServices/PushNotificationsDemo/PushNotificationsDemo/MainPage.xaml.cs b/8.0/WebServices/PushNotificationsDemo/PushNotificationsDemo/MainPage.xaml.cs index 5eb115113..3357ec05e 100644 --- a/8.0/WebServices/PushNotificationsDemo/PushNotificationsDemo/MainPage.xaml.cs +++ b/8.0/WebServices/PushNotificationsDemo/PushNotificationsDemo/MainPage.xaml.cs @@ -1,9 +1,5 @@ using PushNotificationsDemo.Services; -#if ANDROID -using PushNotificationsDemo.Platforms.Android; -#endif - namespace PushNotificationsDemo { public partial class MainPage : ContentPage @@ -15,46 +11,46 @@ public MainPage(INotificationRegistrationService service) InitializeComponent(); _notificationRegistrationService = service; - } - + } + #if ANDROID - protected override async void OnAppearing() - { - base.OnAppearing(); - - PermissionStatus status = await Permissions.RequestAsync(); - } + protected override async void OnAppearing() + { + base.OnAppearing(); + + PermissionStatus status = await Permissions.RequestAsync(); + } #endif - - void OnRegisterButtonClicked(object sender, EventArgs e) + + void OnRegisterButtonClicked(object sender, EventArgs e) { - _notificationRegistrationService.RegisterDeviceAsync() - .ContinueWith((task) => - { - ShowAlert(task.IsFaulted ? task.Exception.Message : $"Device registered"); - }); + _notificationRegistrationService.RegisterDeviceAsync() + .ContinueWith((task) => + { + ShowAlert(task.IsFaulted ? task.Exception.Message : $"Device registered"); + }); } - void OnDeregisterButtonClicked(object sender, EventArgs e) + void OnDeregisterButtonClicked(object sender, EventArgs e) { - _notificationRegistrationService.DeregisterDeviceAsync() - .ContinueWith((task) => - { - ShowAlert(task.IsFaulted ? task.Exception.Message : $"Device deregistered"); - }); + _notificationRegistrationService.DeregisterDeviceAsync() + .ContinueWith((task) => + { + ShowAlert(task.IsFaulted ? task.Exception.Message : $"Device deregistered"); + }); } - void ShowAlert(string message) + void ShowAlert(string message) { - MainThread.BeginInvokeOnMainThread(() => - { - DisplayAlert("Push notifications demo", message, "OK") - .ContinueWith((task) => - { - if (task.IsFaulted) - throw task.Exception; - }); - }); + MainThread.BeginInvokeOnMainThread(() => + { + DisplayAlert("Push notifications demo", message, "OK") + .ContinueWith((task) => + { + if (task.IsFaulted) + throw task.Exception; + }); + }); } } } diff --git a/8.0/WebServices/PushNotificationsDemo/PushNotificationsDemo/Platforms/Android/PushNotificationPermission.cs b/8.0/WebServices/PushNotificationsDemo/PushNotificationsDemo/Platforms/Android/PushNotificationPermission.cs deleted file mode 100644 index 1cd295549..000000000 --- a/8.0/WebServices/PushNotificationsDemo/PushNotificationsDemo/Platforms/Android/PushNotificationPermission.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Android; - -namespace PushNotificationsDemo.Platforms.Android; - -public class PushNotificationPermission : Permissions.BasePlatformPermission -{ - public override (string androidPermission, bool isRuntime)[] RequiredPermissions - { - get - { - var result = new List<(string androidPermission, bool isRuntime)>(); - if (OperatingSystem.IsAndroidVersionAtLeast(33)) - result.Add((Manifest.Permission.PostNotifications, true)); - return result.ToArray(); - } - } -}