Using Firebase 3.4.1 with Ionic 2 Getting Error : Cannot read property 'navigator' of undefined
Hello Everyone I am using Firebase 3.4.1 in ionic 2 app During Building i Got Error
[20:15:06] rollup: Export 'initializeApp' is not defined by '\.tmp\app\app.component.js'
[20:15:06] rollup: Use of `eval` (in \node_modules\firebase\auth.js) is strongly discouraged, as it poses security
risks and may cause issues with minification. See https://github.com/rollup/rollup/wiki/Troubleshooting#avoiding-eval for more details
[20:15:06] rollup: Use of `eval` (in \node_modules\firebase\database.js) is strongly discouraged, as it poses secu
rity risks and may cause issues with minification. See https://github.com/rollup/rollup/wiki/Troubleshooting#avoiding-eval for more details
After Building App console shows
Cannot read property 'navigator' of undefined
In which place do you call firebase#initializeApp? I placed it in the constructor of 'app.ts' and outside the call 'platform.ready' and worked for me. Like so:
_[other imports]_
import * as firebase from 'firebase';
export class MyApp {
public rootPage: any;
constructor(private platform: Platform) {
this.rootPage = TabsPage;
var config = {
apiKey: "XXXXXXXXXXXXXXXX",
authDomain: "XXXXXXXXXXXXXXXX",
databaseURL: "XXXXXXXXXXXXXXXX",
storageBucket: "XXXXXXXXXXXXXXXX",
messagingSenderId: "XXXXXXXXXXXXXXXX"
};
firebase.initializeApp(config);
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
});
}
}
@AntonioRossi app.ts is replaced with app.component.ts in Ionic2 RC 0
I was configuring the config object in provider/service and then importing in app.component.ts
But now i have moved all that code in the app.component.ts. Still no luck, Error Is same, Thanks
Hello all! Thanks for using Ionic! You can check out this link for how to use firebase with RC.0. We are also currently working on our own docs on how to use third party libraries written in commonjs with Ionic 2. Thanks!
@jgw96 Hi Justin - is there a good way to use Firebase without AngularFire?