Thursday, 18 May 2017

"Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app)."

I am trying to use firebase cloud messaging service but I get an error on my web application. I use Ionic for this application. I followed this tutorial : https://firebase.google.com/docs/web/setup.

This is my index.html

     <script src="/__/firebase/4.0.0/firebase-app.js"></script>
  <script src="/__/firebase/4.0.0/firebase-auth.js"></script>
  <script src="/__/firebase/4.0.0/firebase-database.js"></script>
  <script src="/__/firebase/4.0.0/firebase-messaging.js"></script>
  <script src="/__/firebase/init.js"></script>
 <script src="https://www.gstatic.com/firebasejs/3.9.0/firebase.js"></script>
<script>

  const messaging = firebase.messaging();
  // [END get_messaging_object]
  // IDs of divs that display Instance ID token UI or request permission UI.

  // Initialize Firebase
  var config = {
    apiKey: "XXXXXXXXX",
    authDomain: "xxxxxxxxxx",
    databaseURL: "xxxxxxxxxxxx",
    projectId: "xxxxxx",
    storageBucket: "xxxxxxxxx",
    messagingSenderId: "xxxxxxxxxxxx"
  };
  firebase.initializeApp(config);
// Initialize the default app
var defaultApp = firebase.initializeApp(config);

console.log(defaultApp.name);  // "[DEFAULT]"

// You can retrieve services via the defaultApp variable...
var defaultStorage = defaultApp.storage();
var defaultDatabase = defaultApp.database();

// ... or you can use the equivalent shorthand notation
defaultStorage = firebase.storage();
defaultDatabase = firebase.database();

</script>

And the error :

Uncaught e {code: "app/no-app", message: "Firebase: No Firebase App '[DEFAULT]' has been cre…- call Firebase App.initializeApp() (app/no-app).", name: "[DEFAULT]", stack: "FirebaseError: Firebase: No Firebase App '[DEFAULT…e.js:28:4143)↵    at http://localhost:5000/:50:30"}code: "app/no-app"message: "Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app)."name: "[DEFAULT]"stack: "FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).↵    at o (https://www.gstatic.com/firebasejs/3.9.0/firebase.js:28:4732)↵    at e (https://www.gstatic.com/firebasejs/3.9.0/firebase.js:28:3153)↵    at Object.u [as messaging] (https://www.gstatic.com/firebasejs/3.9.0/firebase.js:28:4143)↵    at http://localhost:5000/:50:30"__proto__: Error
o @ firebase-app.js:1677
e @ firebase-app.js:1677
u @ firebase-app.js:1677
(anonymous) @ (index):50
17:14:22.092 util.js:60 Native: tried calling StatusBar.styleDefault, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
cordovaWarn @ util.js:60
checkAvailability @ plugin.js:19
callCordovaPlugin @ plugin.js:107
(anonymous) @ plugin.js:226
value @ decorators.js:130
(anonymous) @ app.component.ts:34
t.invoke @ polyfills.js:3
onInvoke @ core.es5.js:4125
t.invoke @ polyfills.js:3
r.run @ polyfills.js:3
(anonymous) @ polyfills.js:3
t.invokeTask @ polyfills.js:3
onInvokeTask @ core.es5.js:4116
t.invokeTask @ polyfills.js:3
r.runTask @ polyfills.js:3
o @ polyfills.js:3
invoke @ polyfills.js:3



via HeartDeath

No comments:

Post a Comment