'Why is a _react-native-otp-verify_ library call throwing an 'is not a function' error?

I am trying to use a ReactNative package, react-native-otp-verify to implement automatic SMS verification. At this point, I am getting an error though, that I need help with on how to resolve, even though I tried to use it exactly as prescribed in the docs.

Below is also the expo log:

[Unhandled promise rejection: TypeError: _reactNativeOtpVerify.default.getHash is not a function. (In '_reactNativeOtpVerify.default.getHash()', '_reactNativeOtpVerify.default.getHash' is undefined)]
at [native code]:null in performSyncWorkOnRoot
at [native code]:null in dispatchAction
at http://192.168.226.60:19000/index.bundle?platform=android&dev=true&hot=false&minify=false:286125:34 in loadResourcesAndDataAsync$
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue

Code sample of where I am using the package:

.
.
.


import RNOtpVerify from 'react-native-otp-verify';


function HomeScreen(props) {

    const getHash = () =>
        RNOtpVerify.getHash()
            .then(console.log)
            .catch(console.log);

    const startListeningForOtp = () =>
        RNOtpVerify.getOtp()
            .then(p => RNOtpVerify.addListener(this.otpHandler))
            .catch(p => console.log(p));

    const otpHandler = (message) => {
        const otp = /(\d{4})/g.exec(message)[1];
        this.setState({ otp });
        RNOtpVerify.removeListener();
        Keyboard.dismiss();
    }

    useEffect(() => {
        RNOtpVerify.removeListener();
    });
   
   .
   .
   .

At this point, I am also welcoming suggestions for suitable SMS verification alternatives. I have a custom sign-in/signup system, and I want to augment SMS verification to the user registration. Is such a thing possible with only a client library?

Thank you for your time!



Solution 1:[1]

@skj This library seems to have some issues but actually they use this library under the hood react-native-sms-retriever . You can follow their documentation and do it yourself without using another library. Check it out on npmjs here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mistico