1.0.8 • Published 6 years ago

@imnotout/capacitor-firebase-phoneauth v1.0.8

Weekly downloads
-
License
GPLV3
Repository
github
Last release
6 years ago

Capacitor-firebase-phoneauth

This plugins was intended to be used internally at imnotout.com. Works only with Web and iOS. Code can be used as is or for reference under GNU GPLv3 License.

  /**
   * Requests otp from firebase to authenticate and verify phone number.
   * @param options accepts phone number as string with countrycode, eg: +919999999999
   */
  verifyPhoneNumber(options: VerifyPhoneNumberOptions): Promise<void>

  /**
   *  verifies the otp and authenticates a user
   * @param options
   */
  signinWithOtp(options: SigninWithOtpOptions): Promise<{ uid: string }>

  /**
   * Logouts the current authenticated user
   */
  signOut(): Promise<void>

  /**
   * Returns the idToken of current authenticated user
   */
  getIdToken(): Promise<{ token: String }>

  /**
   * Calls callback with user is signed in or out (err, user)
   * @param callback
   */
  onAuthStateChanged(callback: {
    (error: any, user: { uid: string } | null): void
  }): void

Special instructions for web

before calling any method set the fiebase instance to be used since we can't initialise here inside plugin, you may require firebase is required outside the plugin.

/**
 * Set firebase instance for use with web [REQUIRED].
 * You can get the initialized firebase instance from firebase.app()
 * EG: CapacitorFirebasePhoneAuth.setFirebaseInstanceForWeb(fb: firebase.app.App)
 * @param firebase
 */
setFirebaseInstanceForWeb(fb: firebase.app.App):void

Usage

import { Plugins } from "@capacitor/core"

const { CapacitorFirebasePhoneAuth } = Plugins

//Use await or a regular promise
const token = await CapacitorFirebasePhoneAuth.getIdToken()
1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago