From 1a8854a0c75f8053d2f618e0f4ad9f75df49b9c7 Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 15 Feb 2024 18:26:53 +0000 Subject: [PATCH 1/2] Fixed customised notification patterns on Android O and later --- .../Platforms/Android/NotificationServiceImpl.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Plugin.LocalNotification/Platforms/Android/NotificationServiceImpl.cs b/Source/Plugin.LocalNotification/Platforms/Android/NotificationServiceImpl.cs index 597c15e7..b4db17d1 100644 --- a/Source/Plugin.LocalNotification/Platforms/Android/NotificationServiceImpl.cs +++ b/Source/Plugin.LocalNotification/Platforms/Android/NotificationServiceImpl.cs @@ -475,7 +475,18 @@ internal virtual async Task ShowNow(NotificationRequest request) if (request.Android.VibrationPattern is not null) { - builder.SetVibrate(request.Android.VibrationPattern); + if (Build.VERSION.SdkInt >= BuildVersionCodes.O) //O == API level 26.0 + { + // play vibration + var vibrator = Platform.AppContext.GetSystemService(Context.VibratorService) as Vibrator; + if (vibrator == null) + LocalNotificationCenter.Log("Unable to get the Vibrator Service"); + else + vibrator.Vibrate(VibrationEffect.CreateWaveform(request.Android.VibrationPattern, -1)); + + } else { + builder.SetVibrate(request.Android.VibrationPattern); + } } if (request.Android.ProgressBar is not null) From ebe089ea5ca88564950c9f0888883812c272920d Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 22 Feb 2024 11:28:13 +0000 Subject: [PATCH 2/2] Reverted previous change --- .../Platforms/Android/NotificationServiceImpl.cs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/Source/Plugin.LocalNotification/Platforms/Android/NotificationServiceImpl.cs b/Source/Plugin.LocalNotification/Platforms/Android/NotificationServiceImpl.cs index b4db17d1..597c15e7 100644 --- a/Source/Plugin.LocalNotification/Platforms/Android/NotificationServiceImpl.cs +++ b/Source/Plugin.LocalNotification/Platforms/Android/NotificationServiceImpl.cs @@ -475,18 +475,7 @@ internal virtual async Task ShowNow(NotificationRequest request) if (request.Android.VibrationPattern is not null) { - if (Build.VERSION.SdkInt >= BuildVersionCodes.O) //O == API level 26.0 - { - // play vibration - var vibrator = Platform.AppContext.GetSystemService(Context.VibratorService) as Vibrator; - if (vibrator == null) - LocalNotificationCenter.Log("Unable to get the Vibrator Service"); - else - vibrator.Vibrate(VibrationEffect.CreateWaveform(request.Android.VibrationPattern, -1)); - - } else { - builder.SetVibrate(request.Android.VibrationPattern); - } + builder.SetVibrate(request.Android.VibrationPattern); } if (request.Android.ProgressBar is not null)