Check if user is authenticated for the first time in Firebase Google Authentication in Android

后端 未结 8 1434
一向
一向 2020-11-30 06:16

I am using Firebase Authentication in an Android application, and I am using Google account authentication as an option to sign in to the application.

How can I know

8条回答
  •  独厮守ぢ
    2020-11-30 06:47

    While I fully agree that the most correct way (given the inability to add new fields to the auth user table) is to create a new path for users and store info there, I didn't want to make an additional request after logging in to do this check (I'm using Firestore and requests = money).

    I needed to do this first login check to prompt for a userName (as display name is pulled from Facebook/Google and I wanted to give the option of overriding if it's their first login). What I ended up doing was using the photoURL property as a flag to determine if it was their first time or not. It's not ideal but maybe someone that wants to save on requests can use this as a workaround. It's not as big a deal for Firebase but for Firestore it's more costly for your plan

提交回复
热议问题