Haptic.selection crashing on Android

Hi,

I’m attempting to use the Haptic module in my application, which seems to work fine on iOS, however I’m getting a crash on Android of The method or property Haptic.selection is not available on this platform, are you sure you've linked all the native dependencies properly? This would seem to make a bit of sense as the Android platform obviously doesn’t have the haptic engine, however the docs for the module state that “If this is used in Android, the device will use ReactNative.Vibrate instead”, which would seem to suggest that I don’t need to do any additional checks on my end for the platform. Are the docs misleading and I should be checking for the platform before attempting to use haptic (and, if so, should I be checking for the other constraints on the docs, like iOS < 10)?

I have seen this issue, however it seems to deal specifically with Haptic.notification, while I’m attempting to use Haptic.selection.

I’m on a managed application on SDK v32.

Thanks!

Have encountered the same problem for over a month. I’ve settled with the following:

if (Platform.OS === 'android') {
  Vibration.vibrate(50);
} else if (Platform.OS === 'ios') {
  Haptic.selection();
}

Would love if it this was built in as per the docs…

But what’s interesting is that Android should have some sort of Haptic feedback engine. I mean, the vibration you get from Vibration.vibrate(50) is not the same as that light shake you get from tapping the Back arrow…

I can personally understand that the haptic API isn’t available on Android; it’s specifically exposed as part of the iOS API and has a pretty beefy physical component in iOS devices. That said, yeah, it seems like at this point we need to do manual platform checks even with what the docs say, which is disappointing.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.