Vibration.vibrate not working in IOS
What's happening?
Vibration.vibrate not working in react-native-qrcode-scanner http://facebook.github.io/react-native/docs/vibration#vibrate if you take a look of the documentation, the first parameter of the function should be required, i am still not sure why it happens on IOS not android, but pls help to do necessary change.
How can it be reproduced?
<QRCodeScanner
reactivate={true}
vibrate={Platform.OS == "android"} // if i remove this line, the error occurs
reactivateTimeout= {5000}
onRead={this.onSuccess.bind(this)}
cameraStyle={styles.qrReaderCamera}
cameraProps={{ ratio:'1:1' }}
topContent={
<Text style={styles.centerText}>
Go to <Text style={styles.textBold}>wikipedia.org/wiki/QR_code</Text> on your computer and scan the QR code.
</Text>
}
/>
Build details?
happens in Windows 10 and mac version 1.2.1
Snippet from your code
_handleBarCodeRead(e) {
if (!this.state.scanning && !this.state.disableVibrationByUser) {
if (this.props.vibrate) {
Vibration.vibrate(); // this is causing issue as the documentation required first parameter to be required
}
this._setScanning(true);
this.props.onRead(e);
if (this.props.reactivate) {
this._scannerTimeout = setTimeout(
() => this._setScanning(false),
this.props.reactivateTimeout
);
}
}
}
Vibration works on my iOS 13 device. It's weird that they require the first argument, but the documentation also says that the default is 400ms
I'm getting the same issue in my iOS 13 device.
The errors says:
Vibration.vibrate was called with 0 arguments but expects 1 arguments. If you haven't changed this method yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away.
@SmartArray RN has a ticket open on this: https://github.com/facebook/react-native/issues/27920