如何在Web App Javascript上检测用户首次登录Firebase

时间:2019-06-05 01:03:08

标签: javascript firebase firebase-authentication

我正在尝试找出如何在我的Firebase身份验证中检测到帐户的首次登录/注册。我知道我可以在Firebase Firestore中创建布尔值,但这效率很低。有一种方法可以在Android和ios中使用AdditionalUserInfo()来实现。有人知道如何在JavaScript中针对网络应用执行此操作吗?

2 个答案:

答案 0 :(得分:3)

当您在网络应用中调用signInWithCredential()时,它将解析为UserCredential object

它具有一个additionalUserInfo属性,其中包含一个import { MediaRecorder, register } from 'extendable-media-recorder'; import { connect } from 'extendable-media-recorder-wav-encoder'; (async () => { // Get the port a worker which can encode WAV files. const port = await connect(); // Register this port with the MediaRecorder. await register(port); // Request a MediaStream with an audio track. const mediaStream = await navigator.mediaDevices .getUserMedia({ audio: true }); // Create a MediaRecorder instance with the newly obtained MediaStream. const mediaRecorder = new MediaRecorder(mediaStream, { mimeType: 'audio/wav' }); // Kick off the recording. mediaRecorder.start(); mediaRecorder.addEventListener('dataavailable', ({ data }) => { // The data variable now holds a refrence to a Blob with the WAV file. }); // Stop the recording after a second. setTimeout(() => mediaRecorder.stop(), 1000); })(); 值。

答案 1 :(得分:0)

由于我没有足够的声誉来发表评论,因此我也将其保留在这里-

达罗·哈特曼(Darrow Hartman)在接受的答案中引用了signInAndRetrieveDataWithCredential(cred),但也没有弃用。

请使用signInWithCredential(cred)

https://firebase.google.com/docs/reference/js/firebase.auth.Auth#signinwithcredential