Code Monkey home page Code Monkey logo

Comments (25)

mi6crazyheart avatar mi6crazyheart commented on July 21, 2024 1

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.

mi6crazyheart avatar mi6crazyheart commented on July 21, 2024 1

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.

441N143G avatar 441N143G commented on July 21, 2024

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.

mi6crazyheart avatar mi6crazyheart commented on July 21, 2024

When I'm doing changes in "reference.d.ts" file, following error I'm getting

firebase-error-cropped

from nativescript-plugin-firebase.

441N143G avatar 441N143G commented on July 21, 2024

No) u must add this line in reference.d.ts in root dir of project)

from nativescript-plugin-firebase.

mi6crazyheart avatar mi6crazyheart commented on July 21, 2024

@441N143G : Sorry, I added the wrong screenshot. Now, I've updated my Screenshot. You can see.

from nativescript-plugin-firebase.

mi6crazyheart avatar mi6crazyheart commented on July 21, 2024

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.

441N143G avatar 441N143G commented on July 21, 2024

Can u make screen with project structure?

from nativescript-plugin-firebase.

mi6crazyheart avatar mi6crazyheart commented on July 21, 2024

Here is the folder structure of my application

firebase-structure-cropped

from nativescript-plugin-firebase.

441N143G avatar 441N143G commented on July 21, 2024

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.

mi6crazyheart avatar mi6crazyheart commented on July 21, 2024

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.

441N143G avatar 441N143G commented on July 21, 2024

in my project - firebase.d.ts

from nativescript-plugin-firebase.

mi6crazyheart avatar mi6crazyheart commented on July 21, 2024

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.

mi6crazyheart avatar mi6crazyheart commented on July 21, 2024

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.

441N143G avatar 441N143G commented on July 21, 2024

can u put firebase.init(... in constructor() - just 4 test?

from nativescript-plugin-firebase.

mi6crazyheart avatar mi6crazyheart commented on July 21, 2024

I did that also when I saw in your code. But, that's also giving me the same error.

from nativescript-plugin-firebase.

441N143G avatar 441N143G commented on July 21, 2024

error when app just starting or after tap event?(with code in constructor)

from nativescript-plugin-firebase.

441N143G avatar 441N143G commented on July 21, 2024

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.

441N143G avatar 441N143G commented on July 21, 2024

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.

mi6crazyheart avatar mi6crazyheart commented on July 21, 2024

@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.

441N143G avatar 441N143G commented on July 21, 2024

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.

mi6crazyheart avatar mi6crazyheart commented on July 21, 2024

@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.

mi6crazyheart avatar mi6crazyheart commented on July 21, 2024

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.

441N143G avatar 441N143G commented on July 21, 2024

u are welcome)

from nativescript-plugin-firebase.

Melf11 avatar Melf11 commented on July 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.