benjamindean/flutter_vibration

Vibration.hasVibrator() promise false in iOS

Closed this issue · 9 comments

hrshs commented

‍‍‍Vibration.hasVibrator() in iOS always promis false.
I've checked swift code and you get the value of hasVibrator from TARGET_OS_SIMULATOR == 1 and then this code always returns false in physical iOS device.
What's wrong?

Yeah, seems like it's a bug. I'll fix it as soon as I can.

I am having the same issue. I had to downgrade the package for now. Appreciate very much if you can fix it.

hrshs commented

@ZhuBoao I called Vibration.hasVibrator() only in android platform. I think it didn't cause any problem because the developer just check the device is physical or simulator.

@ZhuBoao I called Vibration.hasVibrator() only in android platform. I think it didn't cause any problem because the developer just check the device is physical or simulator.

@hrshs I guess the iPad or maybe some iPods running iOS doesn't have any vibrator, so there should be a proper fix on iOS as well. Anyway, if the app only runs on iPhones, I agree we could safely assume that hasVibrator() return true.

@ZhuBoao Which version are you downgrading it to?

@ZhuBoao I created #52 for testing. If you have a physical device to test it on - I would really appreciate it. I don't have any, so that's why iOS code is kind of neglected.

I just published version 1.7.3. Hope it works!

@benjamindean I just tested 1.7.3 on my iPhone X, and it works. Thanks!

Seems like the issue was resolved. Simulator env detection was migrated from Objective-C by mistake.