Setup

To setup firebase on Ionic is necessary to install the Firebase plugin for Ionic.

Installation

Install the Cordova and Ionic Native plugins:

$ ionic cordova plugin add cordova-plugin-firebase

$ npm install --save @ionic-native/firebase

After that is necessary add the plugin to the app's module

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}`));

results matching ""

    No results matching ""