question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VibrationPattern not working as expected

See original GitHub issue

I am having trouble getting VibrationPattern to work. I tried using a pattern where the phone waits for a second and then vibrates for a second and have that done 3 times in a row. However, the actual vibration pattern is the default one for the phone I am testing with (Android 12), more precisely just two bursts of vibration with very little pause in between.

Here is my code:

LocalNotificationCenter.Current.Clear(_notificationId);
var notification = new NotificationRequest
{
    NotificationId = _notificationId,
    Title = $"{period.Name} started!",
    Subtitle = scheduleName,
    Description = $"Period {period.Name} just started!",
    CategoryType = NotificationCategoryType.Alarm,
    Android = new AndroidOptions
    {
        Color = new AndroidColor(period.Color.ToInt()),
        VibrationPattern = new long[] { 1000, 1000, 1000, 1000, 1000, 1000 }
    }
};

await LocalNotificationCenter.Current.Show(notification);

Am I doing something wrong?

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
FikriIsocommented, Jun 26, 2023

@thudugala

thanks for your response.

It’s finally working now. I had to do two things:

  1. move the creation of the channel to mauiprogram.cs: .UseLocalNotification(config => { config.AddAndroid(android => … ETC…

  2. I had to set Silent property (of the NotificationRequest) to false. Apparently this was set to true.

After these changes the virbration works as expected! Thanks again!

0reactions
thudugalacommented, Jun 25, 2023

@IonutArhire and @FikriIso

You can only set the vibration pattern before the channel created.

Have try uninstalling and installing the app again?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Alert - Vibration, not working? : r/tasker
My method is to remove "vibrate" and use "vibrate pattern" instead, on Tasker. It work perfectly and I replaced all my "vibrate" with...
Read more >
Custom vibration pattern for notification stops working in ...
but suddenly the custom vibration stops working until I restarts app (notification pops up with only default vibration, not with my custom one)....
Read more >
Vibration not working even if Silence mod…
First, I'd suggest verifying that Vibration is enabled in Settings > Accessibility > Touch > Vibration. If it's not enabled, tap to enable...
Read more >
android - Notification Sound, Vibration and LED don't work
Based on your comments, it seems to be problem with your phone itself. I was asking in (1) regarding the vibration because you...
Read more >
Phone Not Vibrating; Here's Why? & The Best Fixes
Phone not vibrating? Discover the reasons and best fixes for this issue: Troubleshoot software glitches, updates, and hardware problems.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found