benjamindean / flutter_vibration

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

Vibration.hasVibrator() promise false in iOS #50

Closed hrshs closed 3 years ago

hrshs commented 3 years ago

‍‍‍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?

benjamindean commented 3 years ago

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

ZhuBoao commented 3 years ago

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

hrshs commented 3 years ago

@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 commented 3 years ago

@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.

benjamindean commented 3 years ago

@ZhuBoao Which version are you downgrading it to?

benjamindean commented 3 years ago

@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.

benjamindean commented 3 years ago

I just published version 1.7.3. Hope it works!

ZhuBoao commented 3 years ago

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

benjamindean commented 3 years ago

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