项目作者: BlueMessaging

项目描述 :
Cordova plugin for Google Firebase Realtime Database Based on the the Firebase Notification / FCM plugin
高级语言: Objective-C
项目地址: git://github.com/BlueMessaging/cordova-plugin-firebase-realtime-database.git


cordova-plugin-firebase-realtime-database

Cordova plugin for Google Firebase Realtime Database
Based on the the Firebase Notification / FCM plugin https://github.com/arnesson/cordova-plugin-firebase

Installation

See npm package for versions - https://www.npmjs.com/package/cordova-plugin-firebase-realtime-database

Install the by running:

  1. cordova plugin add cordova-plugin-firebase-realtime-database --save

Download your Firebase configuration files, GoogleService-Info.plist for iOS and google-services.json for Android, and place them in the root folder of your Cordova project:

  1. - My Project/
  2. platforms/
  3. plugins/
  4. www/
  5. config.xml
  6. google-services.json <--
  7. GoogleService-Info.plist <--
  8. ...

See https://support.google.com/firebase/answer/7015592 for details how to download the files from firebase.

This plugin uses a hook (after prepare) that copies the configuration files to the right place, namely platforms/ios/\/Resources for iOS and platforms/android for Android.

Note that the Firebase SDK requires the configuration files to be present and valid, otherwise your app will crash on boot or Firebase features won’t work.

Notes about PhoneGap Build

Hooks does not work with PhoneGap Build. This means you will have to manually make sure the configuration files are included. One way to do that is to make a private fork of this plugin and replace the placeholder config files (see src/ios and src/android) with your actual ones.

Methods

ref

Get a reference to a child path:

  1. var firebaseThings = window.FirebaseDatabasePlugin.ref('things');

this is the preferred way to use FirebaseDatabasePlugin

updateChildren

At a particular reference, update the given keys:

  1. firebaseThings.updateChildren({
  2. 'thing1' : 'aaa',
  3. 'thing2' : 'bbb'
  4. });

returns Promise

setValue

At a particular reference, set the given value:

  1. firebaseThings.child('thing1').setValue('ccc');

returns Promise

setDatabasePersistent

Choose whether data should be persisted on disk, i.e. between app relaunches

  1. window.FirebaseDatabasePlugin.setDatabasePersistent(true);

signInWithEmailAndPassword

Choose whether data should be persisted on disk, i.e. between app relaunches

  1. window.FirebaseDatabasePlugin.signInWithEmailAndPassword(email, password);

returns Promise