如何实现本机 otp 检索器并为应用程序生成哈希键 [英] How to Implement react native otp retriever and generate hash key for application

查看:61
本文介绍了如何实现本机 otp 检索器并为应用程序生成哈希键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

React Native 的初学者

我正在尝试使用 react-native-sms-retriever 自动验证 OTP我在项目中实现了以下示例

I am trying to verify OTP automatically using react-native-sms-retriever I have implemented following example in project

示例实现 这个示例不是获取哈希键的方法.你必须通过执行命令手动获取它

Example implemented This exampleis not provudung way to get hash key. you have to get it manually by executing command

当我执行命令时,它不会要求输入密码.它应该询问因为它在这里

When I execute command, it won't ask for password. It should ask because of here it is

我使用波纹管命令生成了调试哈希键在java/bin"文件夹中执行.但它不是

I have generated debug hash key using bellow command executed in 'java/bin' folder. But its not

keytool -exportcert -alias androiddebugkey -keystore '~\.android\debug.keystore' | xxd -p | tr -d "[:space:]" | echo -n com.opick.app cat | sha256sum | tr -d "[:space:]-" | xxd -r -p | base64 | cut -c1-11

如何为发布版本生成哈希键尝试以下返回错误的键

How to generate hash key for release build tried following returns wrong key

keytool -exportcert -alias my-key-alias -keystore my-key.keystore | xxd -p | tr -d "[:space:]" | echo -n com.opick.app `cat` | sha256sum | tr -d "[:space:]-" | xxd -r -p | base64 | cut -c1-11

我已阅读文档,他们说您需要在上面的命令中为 release keystore 添加 path.对我来说,我不工作,请在相同的

I have read document they says you need to add path for release keystore in above command.for me i is not working please update on same

主要挑战是 cmdbash

推荐答案

我已经尝试了两个三个示例,但是我无法获得 release 广告的 hash keydebug 然后我尝试了以下解决方案它工作得很好.您也可以使用此代码获取 hash key,然后您可以继续您的实现

I have tried two three examples but I was not able to get the hash key for release ad debug then I have tried following solution It worked perfectly. Also you can use this code to get hash key and you can continue with your implementation

react-native-otp-verify

以下代码将为您提供发布和调试 apk 的哈希密钥,只需获取密钥并将其复制到某处以供使用

The following code will give you hash key for both release and debug apk just get the key and copy it somewhere for use

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

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

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

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

 componentWillUnmount() {
   RNOtpVerify.removeListener();
 }

这篇关于如何实现本机 otp 检索器并为应用程序生成哈希键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆