benjamindean / flutter_vibration

Handle vibration on iOS and Android in Flutter apps
219 stars 68 forks source link

Create possibility to check if virbration is enabled by user #25

Open devjeff opened 4 years ago

devjeff commented 4 years ago

It would be really cool to check, whether the vibration is enabled by the user, so that one can respect the user settings and vibrate only if the vibration is enabled.

benjamindean commented 4 years ago

What kind of setting do you mean? System setting or app setting? And which platform?

devjeff commented 4 years ago

Hi, I mean the system settings or sometimes it's called "sound profile". On Android you can enable/disable sound and vibration separately via system settings or the corresponding buttons in the notification bar menu. The programmatic access is described in this stackoverflow question for instance.

So, in Android terms I would to retrieve the currently activated ringer mode. I think, there is a similar functionality in iOS, as described here from the users perspective.

benjamindean commented 4 years ago

But what happens now in case vibration is disabled? Does it still vibrate?

devjeff commented 4 years ago

Yes, correct. It still vibrates. I think, the OS (at least Android) doesn't forbid that, as the vibration might indicate an important alarm notification. If you take a look at the [ringtone player plugin](https://pub.dev/packages/flutter_ringtone_player#-readme-tab-, it provides the 'asAlarm' flag for that purpose.

Dieterbe commented 1 year ago

i have the opposite experience. vibration only works if it's enabled in sound settings. I wish i could bypass it. (pixel 6, android 13)