apache / cordova-plugin-vibration

Apache Cordova Vibration Plugin
https://cordova.apache.org/
Apache License 2.0
127 stars 128 forks source link

No vibrations on Android 10 devices #95

Open VaultDeveloper opened 3 years ago

VaultDeveloper commented 3 years ago

Bug Report

Problem

What is expected to happen?

Vibrations.

What does actually happen?

No vibrations.

Command or Code

constructor(private vibration: Vibration)
{
    this.isvcVibration.vibrate(200);
}

Environment, Platform, Device

Only tested on Android devices. Everything is working fine until I use a Android 10 device. I have tested only on 2 Android 10 devices and both doesn't vibrate. Little detail: If I click on the overwiew button (the right physic button on the bottom of the screen), the device vibrates when the app goes in background.

Version information

cordova-plugin-vibration: 3.1.1. cordova-android: 9.0.0 cordova-plugin-androidx: 3.0.0 cordova-plugin-androidx-adapter: 1.1.1 I use the Ionic framework

Checklist

faugusztin commented 3 years ago

My Nokia 7.1 with Android 10 vibrates using this plugin. One thing to note is that 200ms is a really low value, it is the lowest value my phone vibrates at (100ms would not vibrate at all). You should try with longer vibration time (500ms-1000ms) to rule out the length of vibration being an issue, and then also you should try to call the Cordova plugin directly, like navigator.vibrate(500).

VaultDeveloper commented 3 years ago

Thank you for your feedback. I performed additional tests based on the points you mentioned.

Howewer, I try to do vibrations in another screens of my application and everything works fine (even 100 ms vibrations). The only screen where it doesn't works is in the modal I need it. It works in another modal. In this modal I use another plugin, which can also emit vibrations Scandit for Cordova. I wonder if there can't be conflicts between the two plugins.

Also, both Android 10 devices I've tested with are Honor. It is possible that the problem might occur only with the manufacturer.

rchovan commented 2 years ago

Hi, I can confirm this issue, but I have another two cents. Vibration does not work on Android 10/11, tried 500ms too. On Android 7 vibration works.

breautek commented 2 years ago

v3 relies on the browser implementation for implementations. This plugin does not implement vibrations for the android platform itself.

I'd advise checking the JS console by using chrome's remote webview inspector, to see if there are any related error messages such as: Blocked call to navigator.vibrate because user hasn't tapped on the frame or any embedded frame yet.

Potentially related to: https://github.com/apache/cordova-plugin-vibration/issues/110

van9petryk commented 10 months ago

Just use v2 ionic cordova add cordova-plugin-vibration@2.1.6