Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

Vibration.vibrate not working in IOS #197

Open
ghost opened this issue Aug 2, 2019 · 2 comments
Open

Vibration.vibrate not working in IOS #197

ghost opened this issue Aug 2, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 2, 2019

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
        );
      }
    }
  }
@SmartArray
Copy link

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

@eduludi
Copy link

eduludi commented Apr 9, 2020

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: facebook/react-native#27920

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants