Essentials
Essentials copied to clipboard
[Bug] [iOS] Vibration.Vibrate not working in some case
Description
I've created and subscribed to an EventHandler to catch the beginning of an event (in my case the Audio Recorder with a Start to record method) In this method callback, I call the Vibration.Vibrate method of Essentials to vibrate the device. I've double checked the event callback method and also displayed a toast message in this method using the ACR.Userdialogs plugin and the toast is displayed as expected. But the vibration works only Android and not on my iOS devices.
EDIT: To be more precise, the vibration works outside the callback. It failed only when I try to execute the vibration inside the EventHandler callback and only for iOS. But the Toast and the other methods calls works perfectly... it's very weird.
Steps to Reproduce
- Create and Subscribe to an EventHandler to catch the beginning of an event
- In this callback/event method call the Vibration.Vibrate method of the Essentials Plugin
Expected Behavior
The vibration should works on Android AND iOS devices.
Actual Behavior
The vibration works only on Android devices.
Basic Information
- Version with issue: 1.3.1
- Last known good version: -
- IDE: VS for mac
- Platform Target Frameworks:
- iOS: 8.0
- Android: 9.0
- Affected Devices: iPhone 6 with 12.4.3 iPhone 7 Plus with 13.3
Assumption here is you may need to invoke on main thread. Can you try that and see.
Also make sure that your device is set to vibrate on ring.
Yes I already tried that. The only difference it's the call from the Event Handler callback. And yes, the devices are set to vibrate on ring.
Like I said, the vibration works for all of my pages, but not in a Event Handler method on an iOS Device... really weird :x
do you have a small sample we can test out? are you saying like in an event handler for a button click?
@Twelve57 did you ever manage to get this working?
Nope :/
Have the same issue. Any solutions?
do you have a small sample we can test out? are you saying like in an event handler for a button click?
It's simple like that. iOS 14.2 iPhone 11 Pro, XCode 12.2, Xamarin.Essentials 1.5.3.2
public override void ViewDidLoad()
{
//Works
Vibration.Vibrate();
MyButton.TouchUpInside += OnButtonClick;
}
public void OnButtonClick(object sender, EventArgs e)
{
//Not working
Vibration.Vibrate();
//Other stuff
}
What if you call run on main thread in that OnButtonClick?
Tried. Not working too. Also tried this one:
SystemSound.Vibrate.PlayAlertSound();
MainThread.BeginInvokeOnMainThread(() =>
{
SystemSound.Vibrate.PlayAlertSound();
});
Not working too in event handler. But works in view did load method. So I suspect that is Xamarin.iOS bug...
interesting, yeah i think it isn't us at that point, very strange....
Maybe you can use the haptic feedback for this? Maybe newer versions of iOS need new permissions or something?
I tried haptic feedback too and it's not working also. My issue was that I'm using microphone at the same time. It's camera view... So it's not a bug I guess. Can't use vibration with microphone, right?
Any updates?