diff --git a/Plugin.Notifications/Platforms/Android/AndroidConfig.cs b/Plugin.Notifications/Platforms/Android/AndroidConfig.cs index 6e03e72..5e5a0df 100644 --- a/Plugin.Notifications/Platforms/Android/AndroidConfig.cs +++ b/Plugin.Notifications/Platforms/Android/AndroidConfig.cs @@ -8,9 +8,6 @@ namespace Plugin.Notifications { public static class AndroidConfig { - public static int DefaultIcon { get; set; } = GetResourceIdByName("icon"); - public static Android.Net.Uri DefaultSound { get; set; } = Android.Media.RingtoneManager.GetDefaultUri(Android.Media.RingtoneType.Notification); - public static INotificationRepository Repository { get; set; } = new SqliteNotificationRepository(); public static ActivityFlags LaunchActivityFlags { get; set; } = ActivityFlags.NewTask | ActivityFlags.ClearTask; diff --git a/Plugin.Notifications/Platforms/Android/NotificationsImpl.cs b/Plugin.Notifications/Platforms/Android/NotificationsImpl.cs index a2d611d..61e32df 100644 --- a/Plugin.Notifications/Platforms/Android/NotificationsImpl.cs +++ b/Plugin.Notifications/Platforms/Android/NotificationsImpl.cs @@ -75,9 +75,6 @@ public override Task Send(Notification notification) .AddNextIntent(launchIntent) .GetPendingIntent(notification.Id.Value, (int)(PendingIntentFlags.OneShot | PendingIntentFlags.CancelCurrent)); - int iconResId = notification.Icon != null ? AndroidConfig.GetResourceIdByName(notification.Icon) - : AndroidConfig.DefaultIcon; - var builder = new NotificationCompat.Builder(Application.Context) .SetAutoCancel(true) .SetContentIntent(pendingIntent) @@ -85,19 +82,10 @@ public override Task Send(Notification notification) .SetContentText(notification.Message) ; - if (notification.Icon != null) + // ignore PlatformDefault, there's no such thing as an out-of-the-box icon + if (notification.Icon != null && notification.Icon != Notification.PlatformDefault) { - int iconId; - - if (notification.Icon == Notification.PlatformDefault) - { - iconId = AndroidConfig.DefaultIcon; - } - else - { - iconId = AndroidConfig.GetResourceIdByName(notification.Icon); - } - + int iconId = AndroidConfig.GetResourceIdByName(notification.Icon); builder.SetSmallIcon(iconId); } @@ -111,7 +99,7 @@ public override Task Send(Notification notification) if (notification.Sound == Notification.PlatformDefault) { // Fallback to the system default notification sound - uri = AndroidConfig.DefaultSound; + uri = Android.Media.RingtoneManager.GetDefaultUri(Android.Media.RingtoneType.Notification); } else if (!notification.Sound.Contains("://")) { @@ -187,12 +175,12 @@ public override Task SetBadge(int value) public override void Vibrate(int ms) { - using (var vibrate = (Vibrator)Application.Context.GetSystemService(Context.VibratorService)) + using (var vib = Vibrator.FromContext(Application.Context)) { - if (!vibrate.HasVibrator) + if (!vib.HasVibrator) return; - vibrate.Vibrate(ms); + vib.Vibrate(VibrationEffect.CreateOneShot(ms, VibrationEffect.DefaultAmplitude)); } } diff --git a/Plugin.Notifications/Platforms/iOS/iOS_Config.cs b/Plugin.Notifications/Platforms/iOS/iOS_Config.cs deleted file mode 100644 index a4510bb..0000000 --- a/Plugin.Notifications/Platforms/iOS/iOS_Config.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using UIKit; - -namespace Plugin.Notifications.Platforms.iOS -{ - public static class Config - { - public static string DefaultIcon { get; set; } - public static string DefaultSound { get; set; } - } -}