0

我正在尝试使用 ReactNative 包react-native-otp-verify来实现自动短信验证。在这一点上,我收到一个错误,我需要有关如何解决的帮助,即使我尝试完全按照文档中的规定使用它。

以下也是博览会日志:

[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

我在哪里使用包的代码示例:

.
.
.


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();
    });
   
   .
   .
   .

在这一点上,我也欢迎有关合适的 SMS 验证替代方案的建议。我有一个自定义登录/注册系统,我想将 SMS 验证增强到用户注册。仅使用客户端库就可以做到这一点吗?

感谢您的时间!

4

0 回答 0