Flutter教程

Firebase

Contents

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).

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

联系我们?

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic's experts offer official maintenance, support, and integration help.

Contact Us Today!

Ionic Firebase插件的安装(Installation)

ionic cordova plugin add cordova-plugin-firebase npm install @ionic-native/firebase
Ionic EE comes with fully supported and maintained plugins from the Ionic Team. Learn More or Contact Us
ionic enterprise register --key=YOURPRODUCTKEY npm install @ionic-enterprise/firebase

Ionic Firebase插件支持的平台(Supported Platforms)

  • Android
  • iOS

Ionic Firebase插件的用法(Usage)

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

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.onNotificationOpen()
   .subscribe(data => console.log(`User opened a notification ${data}`));

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