Code Monkey home page Code Monkey logo

Comments (51)

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024 1

I'm refactoring things as we speak so I'll definitely check it out. Thanks for your efforts.

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024 1

You said "Reproduced trying the demo for this repo against the same firebase I've been using. Same behavior, the console says a key was created but no new data appears." so I guess you cloned this repo and followed the instructions in the readme. Since that's using Firebase 2.x you don't need to add google-services.json etc because that's a Firebase 3.x requirement.

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024 1

That's hardly ignorant :)

Let me update the demo app first so you can simply clone that.

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024 1

Thanks for all your help!

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

I just deployed my proof of concept from a few weeks ago to my phone again, and that has no trouble writing to firebase.

I believe the only difference in my setup between then and now was that I had to add multiDex to the build.grade in the most recent project.

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

Can add a bit of loggin to the push function of the firebase plugin and see if it's invoking the correct methods at all? I have no idea what's up though, can't reproduce this issue on my sample app.

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

@EddyVerbruggen I added some basic logging to push in firebase.android.js, and the method is getting called with the correct parameters, and the promise is definitely resolving, but still no data in firebase. How else can I help debug this?

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

I'll give it a shot with the sample app linked from the readme and see if that gives me any trouble.

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

Reproduced trying the demo for this repo against the same firebase I've been using. Same behavior, the console says a key was created but no new data appears.

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

Awesome, thanks @EddyVerbruggen

Collected a little more data–I tried the demo against another Firebase instance as a sanity check, same behavior. The only way I'm deviating from the setup in the readme is setting the applicationId in platforms/android/build.gradle instead of the recommended app/App_Resources/Android/app.gradle. I'm doing this because I don't see app/App_Resources/Android/app.gradle in either the advanced seed that I'm using to prototype, or the demo from this repo.

I tried creating a new app/App_Resources/Android/app.gradle and setting just:

android {
    defaultConfig {
        applicationId "com.entercastle.ng2Test"
    }
}

but still no luck.

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

Just tried the demo app again - the 'store by push' button results in:
screen shot 2016-06-17 at 21 01 46

Are your rules the same as mine (evenybody can read/write), or do you authenticate the user before writing?
screen shot 2016-06-17 at 21 03 29

Let me see if moving the applicationId to that file makes a difference for me...

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

@EddyVerbruggen indeed, free-for-all on the permissions:
screen shot 2016-06-17 at 3 07 59 pm

Note: I updated those strings to booleans, still no luck

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

It's a bit weird that you don't have app/App_Resources/Android/app.gradle as that comes standard when starting a new NativeScript app with the CLI. I'm running 2.x, you too?

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

Are you 100% sure your Android device can reach your DB? WiFi connection OK?

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

Running 2.0.1:
screen shot 2016-06-17 at 3 12 56 pm

As for "Are you 100% sure your Android device can reach your DB? WiFi connection OK?", the init succeeds, and my device has no trouble accessing the internet through other channels.

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

OK, asked because if you disable WiFi you can still store data if persist: true is passed in init - and it will sync with the server once you have a conncetion.

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

Hmm, I'll flip that bit and see if that affects anything. I do have it set to persist currently

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

I guess if your Android browser can reach the FB URL you should be fine.

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

No luck with setting persist to false.

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

Puzzled.. the weird this is, the demo app you just tried is using an older version of the plugin (with the Firebase 2.x SDK). Can you just keep it connected to the demo Firebase db and see if that makes a difference? Just clone it without modifications..

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

More data, just tried my prototype of the advanced-seed in a genymotion emulator, same behavior.

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

I'm confused what you mean by just clone it without modifications? Don't I need to add the google-services.json and do the rest of the setup for it to work?

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

Can I clone you repo and run it on my Android device?

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

Well most of the config is in files that aren't tracked by version control (stuff in platforms/android), so I can't easily pass my project. However, I wrote up pretty detailed instructions on my setup here.

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

I cloned the demo repo and ran without any config/setup. The push appears to be working from the console, but I don't have access to the firebase admin, so I can't tell if it's actually writing.

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

Can you run 'store by push' in the demo again and report back the key that's echo'd in the console?

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

Just did a few:

JS: firebase.push done, created key: -KKUsE-bfHox3yL4Iyqe
JS: firebase.push done, created key: -KKUsFPUVzVGVlTfhVfr
JS: firebase.push done, created key: -KKUsFwVYrXgIjxnwFer
JS: firebase.push done, created key: -KKUsu5BumnQ6CfeqICS
JS: firebase.push done, created key: -KKUsuDm6ILN9NIxR95O

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

Crickets..
screen shot 2016-06-17 at 21 43 54

This is so weird. So the old and new version don't work for you.

Firewall issues? Does it matter if your try 3g/4g vs WiFi? πŸ‘Ž

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

Disconnected from wifi and sent a few more:

JS: firebase.push done, created key: -KKUto1cK-VZzejdn0eW
JS: firebase.push done, created key: -KKUtoRME_k8ZTEgOIZM
JS: firebase.push done, created key: -KKUtoZMDYCoouEjBEH-

I really don't think it's a generic network thing because it works fine from web & an iOS emulator.

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

Oh shoot, that's not the correct firebase instance sorry. You're connecting to https://resplendent-fire-4211.firebaseio.com but it should be https://n-plugin-test.firebaseio.com. Please change that here and run again.

That old instance turned up in some kind of limbo state after migrating my account to Firebase 3.

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

Updated the ref:

JS: firebase.push done, created key: -KKUvHpBbWGIlNBR35Ya
JS: firebase.push done, created key: -KKUvIDchsV3uY1W87eP
JS: firebase.push done, created key: -KKUvIJbq2UxCysFBNuq

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

Cool, so the Firebase 2.x plugin/demo push correctly:

screen shot 2016-06-17 at 21 54 26

Can you now connect your app to this Firebase instance? So https://n-plugin-test.firebaseio.com?

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

I'm happy to try, but the setup is different for 2.x and 3.x and my app is using the latest version of this plugin. Is there a specific version you want me to hop back to and try?

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

I'd say just use the latest with what you already have (your app, not the demo) and connect your app to my Firebase instance. The instances are backward compatible and I can clean it up afterwards with one click.

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

"connect your app to my Firebase instance" => Please excuse my ignorance here, but I only know how to do that with the google-services.json file

Is it as simple as adding the url to the init call?

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

More data: I have one instance on my machine of the angular2-advanced-seed from a few weeks ago where this plugin was working fine, iOS & Android. I was looking at the difference in npm dependencies across the projects and noticed this plugin differed by a minor update (3.0.0 in my project that's working, 3.1.0 in my latest). Unfortunately, I got the same behavior when explicitly using 3.0.0 in my latest: the push promise still resolves, but no data is stored. :[

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

Can you make sure your Google Play services stuff is up to date by running android in a terminal and updating those bits?

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

I installed the versions in the SO post linked from the readme. Currently on Google Play Services (rev 30) and Google Repository (rev 26). Currently updating Google Repository to rev 28

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

In other news: I've just pushed 3.1.0 to npm and update the demo app so please clone it, follow the steps in the README of that repo (!) and don't change google-services.json so you connect to my Firebase instance.

(off to bed)

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

Installed and configured with your google-services.json, then tried a few pushes:

JS: firebase.push done, created key: -KKVL21TlTVNZvRI43zO
JS: firebase.push done, created key: -KKVL2Zp7Lt_ZEY61r5P
JS: firebase.push done, created key: -KKVL2llq6c3nrg49xHe

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

Yes! Those 3 at the bottom arrived at y Firebase instance:

screen shot 2016-06-18 at 10 08 02

So what happens if you now add your google-services.json to the demo app? Make sure the applicationId is the same as the one in this file, etc.

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

Amazing, that's working for me. I'll keep you posted on whether or not 3.1.0 resolves the issue in my prototype. Thanks again for all your help so far. πŸ‘

from nativescript-plugin-firebase.

matdehaast avatar matdehaast commented on July 21, 2024

Sorry just to chime in here. Could the issue not have something to do with the fact that new projects created in the new firebase console are not backward compatible with the javascript firebase 2.x.x SDK?

IE Old projects there were migrated would work with 2.x.x and 3.x.x firebase SDK but new projects are only able to use 3.x.x.

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

I ran into a similar experience with web @matdehaast. I couldn't authenticate from the 2.X SDK to a new firebase instance created from the google console, but their customer support verified the claim in the migration guide that the 2.X SDK should still work if you migrate from firebase.com. I'm yet to verify their claim.

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

@EddyVerbruggen so the demo is working when I swap your google-services.json for mine, but when I start a fresh angular2-advanced-seed and follow these instructions, I'm still getting the same behavior from before: the call to push resolves, but no data is stored in firebase:

// libs
import {Store} from '@ngrx/store';

// app
import {FormComponent} from '../../frameworks/core.framework/index';
import {NameListService} from '../../frameworks/app.framework/index';

var firebase = require('nativescript-plugin-firebase');

@FormComponent({
  moduleId: module.id,
  selector: 'sd-home',
  templateUrl: 'home.component.html',
  styleUrls: ['home.component.css']
})
export class HomeComponent {
  public newName: string = '';
  constructor(private store: Store<any>, public nameListService: NameListService) { 
    firebase.init({
      persist: true // Allow disk persistence. Default false.
    }).then((instance:any) => {
      console.log('firebase.init successful'); //succeeds
      firebase.push('/counters', 100).then((result:any) => {
        console.log('pushed', result.key); //logs a key
      }, (err:any) => console.log(err));
    }, (error:any) => {
      console.log('firebase.init error: ' + error);
    });
  }

  /*
   * @param newname  any text as input.
   * @returns return false to prevent default form submit behavior to refresh the page.
   */
  addName(): boolean {
    this.nameListService.add(this.newName);
    this.newName = '';
    return false;
  }
}

from nativescript-plugin-firebase.

EddyVerbruggen avatar EddyVerbruggen commented on July 21, 2024

@lowe0292 Is it incorrect for me to say that if the plugin works in the demo app and not in some other app the problem is not with the plugin but with the other app?

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

That sounds like solid logic to me.

from nativescript-plugin-firebase.

NathanWalker avatar NathanWalker commented on July 21, 2024

@lowe0292 did you ever find a solution here? Reading through the comments, very curious indeed.

from nativescript-plugin-firebase.

lowe0292 avatar lowe0292 commented on July 21, 2024

@NathanWalker nope, never solved it with your seed. In fact, this was the Achilles heel that killed our NativeScript project. 😒

from nativescript-plugin-firebase.

NathanWalker avatar NathanWalker commented on July 21, 2024

@lowe0292 sry to hear, completely understand though. Lot of interesting details above.
If you have a branch or the project laying around, I'd love to fire it up and try to debug it myself!
Lemme know πŸ‘ And we could put this mystery to rest.

from nativescript-plugin-firebase.

titomitto avatar titomitto commented on July 21, 2024

I also had the same problem. The Solution was Just to change the firebase realtime database settings ( read and write) to true. Being public, android could now read and write to the database.
image

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.