import { Injectable } from '@angular/core'; import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Observable } from 'rxjs/Observable'; /** * @name Firebase * @description * 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). * * @usage * ```typescript * 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}`)); * * ``` */ @Plugin({ pluginName: 'Firebase', plugin: 'cordova-plugin-firebase', pluginRef: 'FirebasePlugin', repo: 'https://github.com/arnesson/cordova-plugin-firebase', platforms: ['Android', 'iOS'] }) @Injectable() export class Firebase extends IonicNativePlugin { /** * Get the device token * @return {Promise} */ @Cordova() getToken(): Promise { return; } /** * Get notified when a token is refreshed * @return {Observable} */ @Cordova({ observable: true }) onTokenRefresh(): Observable { return; } /** * Get notified when the user opens a notification * @return {Observable} */ @Cordova({ observable: true }) onNotificationOpen(): Observable { return; } /** * Grant permission to receive push notifications * @return {Promise} */ @Cordova({ platforms: ['iOS'] }) grantPermission(): Promise { return; } /** * Check permission to receive push notifications * @return {Promise} */ @Cordova() hasPermission(): Promise { return; } /** * Set icon badge number. Set to 0 to clear the badge. * @param badgeNumber {number} * @return {Promise} */ @Cordova() setBadgeNumber(badgeNumber: number): Promise { return; } /** * Get icon badge number * @return {Promise} */ @Cordova() getBadgeNumber(): Promise { return; } /** * Subscribe to a topic * @param topic {string} * @return {Promise} */ @Cordova() subscribe(topic: string): Promise { return; } /** * Unsubscribe from a topic * @param topic {string} * @return {Promise} */ @Cordova() unsubscribe(topic: string): Promise { return; } /** * Log an event using Analytics * @param type {string} * @param data {Object} * @return {Promise} */ @Cordova() logEvent(type: string, data: any): Promise { return; } /** * Log an Error using FirebaseCrash * @param message {string} * @return {Promise} */ @Cordova() logError(message: string): Promise { return; } /** * Set the name of the current screen in Analytics * @param name {string} Screen name * @return {Promise} */ @Cordova() setScreenName(name: string): Promise { return; } /** * Set a user id for use in Analytics * @param userId {string} * @return {Promise} */ @Cordova() setUserId(userId: string): Promise { return; } /** * Set a user property for use in Analytics * @param name {string} * @param value {string} * @return {Promise} */ @Cordova() setUserProperty(name: string, value: string): Promise { return; } /** * Fetch Remote Config parameter values for your app * @param cacheExpirationSeconds * @return {Promise} */ @Cordova({ successIndex: 1, errorIndex: 2 }) fetch(cacheExpirationSeconds?: number): Promise { return; } /** * Activate the Remote Config fetched config * @return {Promise} */ @Cordova() activateFetched(): Promise { return; } /** * Retrieve a Remote Config value * @param key {string} * @param namespace {string} * @return {Promise} */ @Cordova({ successIndex: 2, errorIndex: 3 }) getValue(key: string, namespace?: string): Promise { return; } /** * Retrieve a Remote Config byte array * @param key {string} * @param namespace {string} * @return {Promise} */ @Cordova({ platforms: ['Android'], successIndex: 2, errorIndex: 3 }) getByteArray(key: string, namespace?: string): Promise { return; } /** * Get the current state of the FirebaseRemoteConfig singleton object * @return {Promise} */ @Cordova({ platforms: ['Android'] }) getInfo(): Promise { return; } /** * Change the settings for the FirebaseRemoteConfig object's operations * @param settings {Object} * @return {Promise} */ @Cordova({ platforms: ['Android'] }) setConfigSettings(settings: any): Promise { return; } /** * Set defaults in the Remote Config * @param defaults {Object} * @param namespace {string} * @return {Promise} */ @Cordova({ platforms: ['Android'], successIndex: 2, errorIndex: 3 }) setDefaults(defaults: any, namespace: string): Promise { return; } }