Firebase

Improve this doc

$ ionic plugin add cordova-plugin-firebase
$ npm install --save @ionic-native/firebase

Repo: https://github.com/arnesson/cordova-plugin-firebase

This plugin brings push notifications, analytics, event tracking, crash reporting and more from Google Firebase to your Cordova project! Android and iOS supported (including iOS 10).

Supported platforms

Usage

import { Firebase } from '@ionic-native/firebase';

constructor(private firebase: Firebase) { }

...

this.firebase.getToken()
  .then(token => console.log(`The token is ${token}`)) // save the token server-side and use it to push notifications to this device
  .catch(error => console.error('Error getting token', error));

this.firebase.onTokenRefresh()
  .subscribe((token: string) => console.log(`Got a new token ${token}`));

Instance Members

getToken()

Get the device token

Returns: Promise<any>

onTokenRefresh()

Get notified when a token is refreshed

Returns: Observable<any>

onNotificationOpen()

Get notified when the user opens a notification

Returns: Observable<any>

grantPermission()

Platforms:iOS 

Grant permission to recieve push notifications

Returns: Promise<any>

hasPermission()

Platforms:iOS 

Check permission to recieve push notifications

Returns: Promise<any>

setBadgeNumber(badgeNumber)

Set icon badge number. Set to 0 to clear the badge.

Param Type Details
badgeNumber number

Returns: Promise<any>

getBadgeNumber()

Get icon badge number

Returns: Promise<any>

subscribe(topic)

Subscribe to a topic

Param Type Details
topic string

Returns: Promise<any>

unsubscribe(topic)

Unsubscribe from a topic

Param Type Details
topic string

Returns: Promise<any>

logEvent(type, data)

Log an event using Analytics

Param Type Details
type string
data Object

Returns: Promise<any>

setScreenName(name)

Set the name of the current screen in Analytics

Param Type Details
name string

Screen name

Returns: Promise<any>

setUserId(userId)

Set a user id for use in Analytics

Param Type Details
userId string

Returns: Promise<any>

setUserProperty(name, value)

Set a user property for use in Analytics

Param Type Details
name string
value string

Returns: Promise<any>

fetch(cacheExpirationSeconds)

Platforms:Android 

Fetch Remote Config parameter values for your app

Param Type Details
cacheExpirationSeconds

Returns: Promise<any>

activateFetched()

Platforms:Android 

Activate the Remote Config fetched config

Returns: Promise<any>

getValue(key, namespace)

Platforms:Android 

Retrieve a Remote Config value

Param Type Details
key string
namespace string

Returns: Promise<any>

getByteArray(key, namespace)

Platforms:Android 

Retrieve a Remote Config byte array

Param Type Details
key string
namespace string

Returns: Promise<any>

getInfo()

Platforms:Android 

Get the current state of the FirebaseRemoteConfig singleton object

Returns: Promise<any>

setConfigSettings(settings)

Platforms:Android 

Change the settings for the FirebaseRemoteConfig object’s operations

Param Type Details
settings Object

Returns: Promise<any>

setDefaults(defaults, namespace)

Platforms:Android 

Set defaults in the Remote Config

Param Type Details
defaults Object
namespace string

Returns: Promise<any>

API

Native

General