Comments (25)
I'm using tns livesync android --watch
. So, just after saving the file when compiler start compiling once again.. I'm getting that error.
from nativescript-plugin-firebase.
YES. I've setup that also. But, does that can be the reason for the error - " Cannot read property 'firebase' of undefined" ? I don't feel so. I can also be wrong.
from nativescript-plugin-firebase.
import firebase = require("nativescript-plugin-firebase");
in reference.d.ts add /// <reference path="./node_modules/nativescript-plugin-firebase/firebase" />
(without extensions)
from nativescript-plugin-firebase.
When I'm doing changes in "reference.d.ts" file, following error I'm getting
from nativescript-plugin-firebase.
No) u must add this line in reference.d.ts in root dir of project)
from nativescript-plugin-firebase.
@441N143G : Sorry, I added the wrong screenshot. Now, I've updated my Screenshot. You can see.
from nativescript-plugin-firebase.
I think, I need to add "extension" in the path. But, which 'ts' file I need to point. There are 2 'ts' files.
- firebase-common.d.ts
- firebase.d.ts
By, adding extension to the file path error is getting resolved. But, I don't understand to which TS file I need to point.
from nativescript-plugin-firebase.
Can u make screen with project structure?
from nativescript-plugin-firebase.
Here is the folder structure of my application
from nativescript-plugin-firebase.
Maybe this help: This is how looks files in my test app (native, angular2, firebase, created with: tns create tesеApp --ng) (works as expected):
reference.dt.ts(in root folder):
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.d.ts" /> Needed for autocompletion and compilation. /// <reference path="./node_modules/nativescript-plugin-firebase/firebase" />
app.component.ts:
import {Component} from "@angular/core"; import firebase = require("nativescript-plugin-firebase"); @Component({ ... export class AppComponent { public counter: number = 16; constructor() { firebase.init(<any>{ persist: true // Allow disk persistence. Default false. }).then( function(instance) { console.log("firebase.init done"); }, function(error) { console.log("firebase.init error: " + error); } ); ...
from nativescript-plugin-firebase.
Can you tell which file path I should give in "reference path" link ? It should point to firebase-common.d.ts
or firebase.d.ts
?
from nativescript-plugin-firebase.
in my project - firebase.d.ts
from nativescript-plugin-firebase.
If I point reference path link to "firebase.d.ts" then IntelliSense is not giving any error. But, at the compiling time, I'm getting the same error.
JS: Clicked on Login button
JS: Error in firebase.init: TypeError: Cannot read property 'firebase' of undefined
JS: firebase.init error: TypeError: Cannot read property 'firebase' of undefined
from nativescript-plugin-firebase.
Is following code is fine ?
import {Component} from "@angular/core";
import {User} from "./shared/user/user";
import {UserService} from "./shared/user/user.service";
import {HTTP_PROVIDERS} from "@angular/http";
import firebase = require("nativescript-plugin-firebase");
@Component({
selector: "my-app",
providers: [UserService, HTTP_PROVIDERS],
templateUrl: "pages/login/login.html",
styleUrls: ["pages/login/login-common.css", "pages/login/login.css"]
})
export class AppComponent {
user: User;
isLoggingIn = true;
constructor(private _userService: UserService) {
this.user = new User();
}
submit() {
if (this.isLoggingIn) {
this.login();
} else {
this.signUp();
}
}
login() {
// TODO: Define
console.log('Clicked on Login button');
firebase.init(<any>{
persist: true // Allow disk persistence. Default false.
}).then(
function (instance) {
console.log("firebase.init done");
},
function (error) {
console.log("firebase.init error: " + error);
}
);
}
signUp() {
this._userService.register(this.user);
}
toggleDisplay() {
this.isLoggingIn = !this.isLoggingIn;
}
}
from nativescript-plugin-firebase.
can u put firebase.init(... in constructor() - just 4 test?
from nativescript-plugin-firebase.
I did that also when I saw in your code. But, that's also giving me the same error.
from nativescript-plugin-firebase.
error when app just starting or after tap event?(with code in constructor)
from nativescript-plugin-firebase.
Do u do this: google-services.json which you'll add to your NativeScript project at platforms/android/google-services.json ?
from nativescript-plugin-firebase.
it's seems your code want execute "undefined.firebase". u have many way to get undefined) i thought there something like this: some code try execute "this.firebase...." but context of "this" is lost. Maybe author of plugin will help u better.
from nativescript-plugin-firebase.
@441N143G : Just for curiosity here is my package.json file. Is it fine or there is some problem.
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.bhramaan",
"tns-android": {
"version": "2.0.0"
}
},
"dependencies": {
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/platform-server": "2.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.1",
"nativescript-angular": "0.1.1",
"nativescript-plugin-firebase": "^3.0.1",
"tns-core-modules": "^2.0.0"
},
"devDependencies": {
"babel-traverse": "6.9.0",
"babel-types": "6.9.0",
"babylon": "6.8.0",
"filewalker": "0.1.2",
"lazy": "1.0.11",
"nativescript-dev-typescript": "^0.3.2",
"typescript": "^1.8.10"
},
"android": {
"defaultConfig": {
"applicationId" : "org.nativescript.bhramaan"
}
}
}
from nativescript-plugin-firebase.
Maybe try create clear project with: tns ctreate myMegaProj --ng ?) if u'll have same trouble when added plugin - u can use any native "sugar" without plugins - just read docs: https://docs.nativescript.org/core-concepts/accessing-native-apis-with-javascript
from nativescript-plugin-firebase.
@441N143G - As I told you yesterday that, I'm using tns livesync android --watch
at the time of development. But today, I discovered a build issue when I'm once tried the command tns run android
. For that I've open an issue at here - #41
But, plugin author is telling it's not seems plugin related issue. But, now I feel all these issue are coming because of that build issue. If I can able to resolve that one then, may be this issue also get resolve.
But, I've no idea what's the problem & where is the issue is. Currently thinking, to open an issue in 'NativeScript' repository it self.
from nativescript-plugin-firebase.
As issue - #41 resolved which also resolved this ongoing issue I'm going to close the thread. @441N143G Again, thank you a lot.
from nativescript-plugin-firebase.
u are welcome)
from nativescript-plugin-firebase.
i had the same problem and finally just reinstalled plugin
npm plugin remove nativescript-plugin-firebase
npm plugin add nativescript-plugin-firebase
from nativescript-plugin-firebase.
Related Issues (20)
- M1 Issue - FirebaseSDK HOT 4
- Several "session_start" event are created on iOS 15 HOT 1
- ERROR TypeError: firebase.init is not a function.
- AdMob error: TypeError: Cannot set property 'resolve' of undefined
- Class constructor ContentView cannot be invoked without 'new'
- Android App Not working with NS 8.2. HOT 42
- A problem occurred configuring root project 'firebase'.
- microsoft login
- Android 12 background notification led to crash (PendingIntent) HOT 6
- Unable to run new deployment HOT 1
- ion
- Error trying to install @nativescript/firebase
- barcode scanning issue - iPhone 13 Pro and iPhone 13 Pro max
- Cannot read property 'ads' of undefined on NativeScript 8.2.3 HOT 1
- Plugin with id 'com.google.gms.google-services' not found. HOT 13
- SetValue of type Date Error on iOS
- Barcode Scanning issue on native script 8 with native camera control
- Mark this repository as deprecated HOT 1
- Firebase Authentication functions are giving error "No reference found.
- Firebase Messaging crash issue in Android 13 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nativescript-plugin-firebase.