EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 444 forks source link

Cannot read property 'firebase' of undefined #1544

Open PetroSuch opened 4 years ago

PetroSuch commented 4 years ago

When i call firebase.addOnMessageReceivedCallback((message:any) => {}) i get error Cannot read property 'firebase' of undefined

PetroSuch commented 4 years ago

"dependencies": { "@angular/animations": "~8.2.0", "@angular/common": "~8.2.0", "@angular/compiler": "~8.2.0", "@angular/core": "~8.2.0", "@angular/forms": "~8.2.0", "@angular/http": "~8.0.0-beta.10", "@angular/platform-browser": "~8.2.0", "@angular/platform-browser-dynamic": "~8.2.0", "@angular/router": "~8.2.0", "@nativescript/schematics": "^0.6.0", "@nstudio/nativescript-pulltorefresh": "^1.0.1", "@tweenjs/tween.js": "^17.4.0", "digitaltown-nativescript-card-io": "^1.0.1", "lodash": "^4.17.15", "lodash.round": "^4.0.4", "moment": "^2.24.0", "nativescript-angular": "^8.20.3", "nativescript-barcodescanner": "^3.3.2", "nativescript-cardio-custom": "^1.0.3", "nativescript-carousel": "^6.1.1", "nativescript-contacts-lite": "^0.2.6", "nativescript-dom": "^2.0.5", "nativescript-fancyalert": "^3.0.9", "nativescript-fingerprint-auth": "^7.0.1", "nativescript-google-maps-sdk": "^2.9.0", "nativescript-iqkeyboardmanager": "^1.5.1", "nativescript-keyboard-toolbar": "^1.1.0", "nativescript-local-notifications": "^4.1.5", "nativescript-localstorage": "^2.0.1", "nativescript-masked-text-field": "^4.0.3", "nativescript-md5": "^1.0.1", "nativescript-plugin-badge": "^1.0.0", "nativescript-plugin-firebase": "^10.3.3", "nativescript-pulltorefresh": "^2.3.0", "nativescript-screenshot": "0.0.2", "nativescript-secure-storage": "^2.6.0", "nativescript-social-share": "^1.5.2", "nativescript-theme-core": "~1.0.6", "nativescript-ui-chart": "^7.1.1", "nativescript-ui-listview": "^8.0.1", "nativescript-uuid": "0.0.1", "nativescript-zxing": "^1.5.9", "reflect-metadata": "~0.1.12", "rxjs": "^6.4.0", "tns-android": "^6.1.2", "tns-core-modules": "^6.3.2", "tns-ios": "^6.1.1", "zone.js": "^0.9.1" },

AntJW commented 4 years ago

Hi @PetroSutch,

Did you add require("nativescript-plugin-firebase"); to your main entry point file, and const firebase = require("nativescript-plugin-firebase"); to the top of the file where you are calling firebase.addOnMessageReceivedCallback?

Not sure this is much of an issue. That method has been working for me. Maybe you can share more details, or a code snippet.