背景:我正在帮助使用 Vue 更新 Cordova 应用程序,以从基于订阅的收入(用户必须付费才能访问该应用程序)转变为基于广告的收入(用户可以免费注册,但当他们使用应用程序时,应用程序中会显示广告。我们想要做的一部分是限制用户可以拥有帐户的设备数量,以避免有人决定与一千个朋友共享他们的付费帐户。我希望效仿 Netflix 对他们帐户的做法。
这是我想到的使用电子邮件/密码身份验证的工作流程(https://firebase.google.com/docs/reference/js/firebase.auth.Auth#signinwithemailandpassword)
// I would like to have device information at this point in the application
firebase.auth().signInWithEmailAndPassword(email, password)
.then(function(result) {
// Use Realtime Database to associate the device with the user
})
.catch(function(error) {
// I'd like to catch the "too-many-devices" error here, but if needed, I can use the success handler to check device limits
})
Run Code Online (Sandbox Code Playgroud)
不幸的是,文档中列出的错误代码没有提到“设备太多”之类的错误,这意味着 Firebase 身份验证很可能没有我正在寻找的内置功能。
根据此支持文档(https://support.google.com/firebase/answer/6318039?hl=en),听起来 Firebase Analytics 已经有某种方法来识别设备。如果可能的话我想访问它。我所做的其他搜索似乎总是向我指出身份验证限制(https://firebase.google.com/docs/auth/limits),其中没有提及任何有关独特设备的信息。
是否可以限制用户登录 Firebase …