firebase - 在 React Native 中将 Touch ID 与 Firebase Auth 集成
问题描述
我是 React native 的新手,但我创建了一个使用 react-native-firebase 包的注册/登录(基于https://github.com/faahmad/react-native-firebase-auth),我想合并touch id 以允许用户登录,但我在网上找不到任何示例(与 firebase 本机反应)。我查看了 react-native-fingerprint-scanner 和 react-native-touch-id 包,它们可以直接实现我只是不知道如何将 firebase auth 和 touch id 联系在一起。对此的任何帮助表示赞赏。
谢谢
解决方案
这只是一个想法,尚未实现为“实际代码”,但是......这是我如何处理它的两分钱:
用户注册后,您可以使用AsyncStorage、SQLite或其他方式存储他们的电子邮件和密码。然后在用户的设置页面中添加Login with fingerprint
为功能。从那里,一旦用户决定再次登录,您可以:
1-使用react-native-fingerprint-scanner
给你的承诺。
2- 从您选择的数据库中获取电子邮件和密码。
3- 使用该数据通过 firebase 进行身份验证并登录。
它看起来像这样:
handleLogin() {
FingerprintScanner
.authenticate({ description: 'Scan your fingerprint to login' })
.then(() => {
const sql = "select email, password from user";
db.runQuery(sql, function(data) { // this is a made-up function
const { email, pasword } = data
firebase
.auth()
.signInWithEmailAndPassword(email, password)
.then(() => /*navigate to main page once authenticated*/)
.catch(error => this.setState({ errorMessage: error.message
});
})
.catch(console.error);
}
有改进的余地,但这应该适合你。希望能帮助到你。
推荐阅读
- css - 替代 img:[alt]hover:after
- html - 带有 aria 角色网格的基于列的布局
- python - Python:multiprocessing.map 因 queue.FULL 而失败
- robotframework - 如何关闭 RIDE 中的单元格数据匹配突出显示?
- grails - 使用带有 rabbitmq-native 插件 (3.4.4) 的 Grails 3.3.2,prefetch=1 的单个消费者在发生异常后停止消费消息
- powerbi-embedded - Power BI Embedded 移动布局不起作用
- java - 使用JPA将UUID作为字符串存储在mysql中
- angular - 如何使用离子框架刷卡
- javascript - 如何知道 puppeteer 实例是否已经存在?
- mysql - Mysql:在where子句中使用连接表列值