2

I've been trying to call Firebase Cloud Functions from my Ionic app using the callable syntaxis as described in Firebase Documentation

I also found this previous question here in StackOverflow, which seems to be the right answer I was looking for...

The problem I have, is that I cannot build my code using "ionic build" because it is give me the following error: Property 'functions' does not exist on type 'FirebaseApp'

My code looks like this:

import firebase from 'firebase';
import '@firebase/functions';
import { ConfigSettings } from '../shared/app.config';

const firebaseApp = firebase.initializeApp(ConfigSettings);
const functions = firebaseApp.functions();

And here are the dependecies in my package.json:

"dependencies": {
  "@angular/common": "5.0.3",
  "@angular/compiler": "5.0.3",
  "@angular/compiler-cli": "5.0.3",
  "@angular/core": "5.0.3",
  "@angular/forms": "5.0.3",
  "@angular/http": "5.0.3",
  "@angular/platform-browser": "5.0.3",
  "@angular/platform-browser-dynamic": "5.0.3",
  "@firebase/functions": "^0.1.0",
  "@ionic-native/contacts": "^4.6.0",
  "@ionic-native/core": "4.4.0",
  "@ionic-native/facebook": "^4.5.3",
  "@ionic-native/firebase-dynamic-links": "^4.6.0",
  "@ionic-native/google-plus": "^4.5.3",
  "@ionic-native/social-sharing": "^4.6.0",
  "@ionic-native/splash-screen": "4.4.0",
  "@ionic-native/status-bar": "4.4.0",
  "@ionic/pro": "1.0.20",
  "@ionic/storage": "^2.1.3",
  "angularfire2": "^5.0.0-rc.6",
  "cordova-android": "6.4.0",
  "cordova-plugin-contacts": "^3.0.1",
  "cordova-plugin-device": "^2.0.1",
  "cordova-plugin-facebook4": "^1.9.1",
  "cordova-plugin-firebase-dynamiclinks": "^0.13.1",
  "cordova-plugin-googleplus": "^5.2.1",
  "cordova-plugin-ionic-keyboard": "^2.0.5",
  "cordova-plugin-ionic-webview": "^1.1.16",
  "cordova-plugin-splashscreen": "^5.0.2",
  "cordova-plugin-whitelist": "^1.3.3",
  "cordova-plugin-x-socialsharing": "^5.3.2",
  "cordova-sqlite-storage": "^2.2.1",
  "cordova-support-google-services": "^1.1.0",
  "cors": "^2.8.4",
  "es6-promise-plugin": "^4.2.2",
  "firebase": "^4.12.1",
  "ionic-angular": "3.9.2",
  "ionicons": "3.0.0",
  "rxjs": "5.5.2",
  "sw-toolbox": "3.6.0",
  "zone.js": "0.8.18"
}

1 Answers1

-1

You shouldn't be trying to compile the @firebase/functions package in with your Ionic App.

Functions are called locally to test your builds - they shouldn't be bundled with your app. When your app is compiled you would call your functions through their correct method such as the Real Time Database triggers, or HTTP triggers instead of using the @firebase/functions package.

Instructions that you linked to are for setup on your development environment. These are separate from your application build - perhaps you should try to make these stand-alone files in a separate directory exclusive of your Ionic App so they don't get mixed up.

sketchthat
  • 2,678
  • 2
  • 13
  • 22
  • 2
    That seems to be a bit misleading. The documentation clearly states that you can call functions either via HTTP or via their internal API wrapper (firebase.functions()). There is definitely a problem in the npm firebase package, as it doesn't import the types of functions module properly, hence problems. For now, you can just call it firebaseApp['functions']() – rattkin Apr 25 '18 at 14:29