jeudi 25 mars 2021

Is there a way to dynamically assign a country to defaultCountry in firebase phone authentication for web?

I am trying to use firebase phone authentication for web and vuejs. I want to detect the country of the user and assign the detected country as the defaultCountry in the firebaseui config.

signInOptions: [
            firebase.auth.EmailAuthProvider.PROVIDER_ID,
            {
                provider: firebase.auth.PhoneAuthProvider.PROVIDER_ID,
                recaptchaParameters: {
                    type: 'image',
                    size: 'invisible',
                    badge: 'bottomleft'
                },
                defaultCountry: `'${this.countryCode}'`
            }
        ]

Below is the method I used to successfully get the country and assign to a variable in data ()

created() {
    this.getDefaultCountry()
},

I even tried

defaultCountry: this.countryCode

If I hardcode a countryCode ('US', 'NZ', ... ), it works.

Thank you




Aucun commentaire:

Enregistrer un commentaire