evertonrobertoauler / cordova-plugin-firebase-authentication

Cordova plugin for Firebase Authentication

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cordova-plugin-firebase-authentication
NPM version NPM downloads

Cordova plugin for Firebase Authentication

Installation

cordova plugin add cordova-plugin-firebase-authentication --save

If you need to set a specific dependency version on Android then use variable FIREBASE_VERSION.

To use phone number authentication on iOS, your app must be able to receive silent APNs notifications from Firebase. For iOS 8.0 and above silent notifications do not require explicit user consent and is therefore unaffected by a user declining to receive APNs notifications in the app. Thus, the app does not need to request user permission to receive push notifications when implementing Firebase phone number auth.

Supported Platforms

  • iOS
  • Android

Methods

Every method call returns a promise which is optionally fulfilled with an appropriate value.

getIdToken(forceRefresh)

Returns a JWT token used to identify the user to a Firebase service.

cordova.plugins.firebase.auth.getIdToken().then(function(idToken) {
    // send token to server
});

createUserWithEmailAndPassword(email, password)

Tries to create a new user account with the given email address and password.

cordova.plugins.firebase.auth.createUserWithEmailAndPassword("my@mail.com", "pa55w0rd");

sendEmailVerification()

Initiates email verification for the current user.

cordova.plugins.firebase.auth.sendEmailVerification();

sendPasswordResetEmail(email)

Triggers the Firebase Authentication backend to send a password-reset email to the given email address, which must correspond to an existing user of your app.

cordova.plugins.firebase.auth.sendPasswordResetEmail("my@mail.com");

signInWithEmailAndPassword(email, password)

Asynchronously signs in using an email and password.

cordova.plugins.firebase.auth.signInWithEmailAndPassword("my@mail.com", "pa55w0rd").then(function(userInfo) {
    // user is signed in
});

verifyPhoneNumber(phoneNumber)

Starts the phone number verification process for the given phone number.

NOTE: Android supports auto-verify and instant device verification. Therefore in that cases it doesn't make sense to ask for sms code. It's recommended to register onAuthStateChanged callback to be notified on auto sign-in.

cordova.plugins.firebase.auth.verifyPhoneNumber("+123456789").then(function(verificationId) {
    // pass verificationId to signInWithVerificationId
});

signInWithVerificationId(verificationId, smsCode)

Asynchronously signs in using verificationId and 6-digit SMS code.

cordova.plugins.firebase.auth.signInWithVerificationId("djgfioerjg34", "123456").then(function(userInfo) {
    // user is signed in
});

signInAnonymously()

Create and use temporary anonymous account to authenticate with Firebase.

cordova.plugins.firebase.auth.signInAnonymously().then(function(userInfo) {
    // user is signed in
});

signInWithGoogle(idToken, accessToken)

Uses Google's idToken and accessToken to sign-in into firebase account. In order to retriave those tokens follow instructions for Android and iOS.

signInWithFacebook(accessToken)

Uses Facebook's accessToken to sign-in into firebase account. In order to retriave those tokens follow instructions for Android and iOS.

signInWithTwitter(token, secret)

Uses Twitter's token and secret to sign-in into firebase account. In order to retriave those tokens follow instructions for Android and iOS.

onAuthStateChanged(callback)

Registers a block as an auth state did change listener. To be invoked when:

  • The block is registered as a listener,
  • A user with a different UID from the current user has signed in, or
  • The current user has signed out.
cordova.plugins.firebase.auth.onAuthStateChanged(function(userInfo) {
    if (userInfo && userInfo.uid) {
        // user was signed in
    } else {
        // user was signed out
    }
});

setLanguageCode(languageCode)

Set's the current user language code. The string used to set this property must be a language code that follows BCP 47.

useAppLanguage()

Sets languageCode to the app’s current language.

signOut()

Signs out the current user and clears it from the disk cache.

cordova.plugins.firebase.auth.signOut().then(function() {
    // user was signed out
});

About

Cordova plugin for Firebase Authentication

License:MIT License


Languages

Language:Java 47.3%Language:Objective-C 42.1%Language:JavaScript 10.5%