You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is what I did to include firebase into my native script app. I copied firebase.js file in the app/lib/ folder and from the project root folder, i ran the following command:
tns library add android app/lib/firebase.js
But I get the following error
Warning: File /home/jay/NativeApp/app/lib/firebase.js/project.properties does not exist
shell.js: internal error
Error: ENOTDIR, not a directory '/home/jay/NativeApp/app/lib/firebase.js'
at Object.fs.readdirSync (fs.js:665:18)
at /home/jay/.nvm/v0.10.32/lib/node_modules/nativescript/node_modules/shelljs/src/ls.js:105:10
at Array.forEach (native)
at _ls (/home/jay/.nvm/v0.10.32/lib/node_modules/nativescript/node_modules/shelljs/src/ls.js:65:9)
at /home/jay/.nvm/v0.10.32/lib/node_modules/nativescript/node_modules/shelljs/src/common.js:111:7
at Array.forEach (native)
at Object.expand (/home/jay/.nvm/v0.10.32/lib/node_modules/nativescript/node_modules/shelljs/src/common.js:94:8)
at Object._cp (/home/jay/.nvm/v0.10.32/lib/node_modules/nativescript/node_modules/shelljs/src/cp.js:155:20)
at Object.cp (/home/jay/.nvm/v0.10.32/lib/node_modules/nativescript/node_modules/shelljs/src/common.js:186:23)
at /home/jay/.nvm/v0.10.32/lib/node_modules/nativescript/lib/services/androi
You are trying to add JavaScript library while library add is for native library. You can work with JavaScript libraries only if they do not depend on some DOM or other browser specific API.
Ok , i guess the firebase.js has some DOM stuff, so it's throwing some errors. I tried with the android SDK lib for firebase using tns library add android app/lib/ but still when I declare firebase
var firebaseObj = new Firebase("https://blistering-heat-2473.firebaseio.com");
It throws error Firebase not defined. I checked the folder lib/Android and the library has been included there. Do I need to require it some way into the main-page.js file? Can you show an example for including a .jar file into the native script app.
The onCreate method is in application.android.js in the application module. Try doing it there and check if it works. It should be a better way i think but try doing that to test.
I added the Firebase.setAndroidContext(this); in onCreate method but Reference Error: Firebase is not defined is what I'm getting on running the app.
I checked the lib/Android folder and it has the firebase-client-android-2.2.3.jar file. Do I need to do anything else to get a reference?
@leandroz That's in a native android application that we include using com.firebase.client.Firebase. It doesn't work in NativeScript. It's some other way. If you have tried and were successful using Firebase in NativeScript, post some working code or something for me to follow. Thanks
Activity
enchev commentedon Apr 27, 2015
If you have some native library for iOS and/or Android you can add it to NativeScript application using our CLI library add command.
jay3dec commentedon Apr 27, 2015
@enchev firebase is a third party library. Is there any way we can include this in our native script app and use as we do in any web app?
enchev commentedon Apr 27, 2015
Indeed you can include it using the add command. After that you have full access to the public API of the lib as everything else in the platform.
jay3dec commentedon Apr 27, 2015
Here is what I did to include firebase into my native script app. I copied firebase.js file in the
app/lib/folder and from the project root folder, i ran the following command:But I get the following error
enchev commentedon Apr 27, 2015
You are trying to add JavaScript library while library add is for native library. You can work with JavaScript libraries only if they do not depend on some DOM or other browser specific API.
jay3dec commentedon Apr 27, 2015
No it doesn't depend on anything browser specific. How to include such libraries in native script app. An example would be appreciated .
enchev commentedon Apr 27, 2015
In this case you simply need to place it inside the application and use require() when needed. You can check how we use our Everlive JavaScript SDK in TelerikNEXT app
jay3dec commentedon Apr 27, 2015
Ok , i guess the firebase.js has some DOM stuff, so it's throwing some errors. I tried with the android SDK lib for firebase using
tns library add android app/lib/but still when I declare firebaseIt throws error
Firebase not defined. I checked the folderlib/Androidand the library has been included there. Do I need to require it some way into themain-page.jsfile? Can you show an example for including a .jar file into the native script app.leandroz commentedon Apr 27, 2015
@jay3dec did you check this?
https://www.firebase.com/docs/android/quickstart.html
The
Firebase.setAndroidContext(this);in the onCreate method.jay3dec commentedon Apr 27, 2015
@leandroz Ok, so I need to initialize it before using. But where should I do this when using in Native Script apps ? Any Idea ??
leandroz commentedon Apr 28, 2015
The onCreate method is in application.android.js in the application module. Try doing it there and check if it works. It should be a better way i think but try doing that to test.
jay3dec commentedon Apr 28, 2015
I added the
Firebase.setAndroidContext(this);in onCreate method butReference Error: Firebase is not definedis what I'm getting on running the app.I checked the
lib/Androidfolder and it has thefirebase-client-android-2.2.3.jarfile. Do I need to do anything else to get a reference?leandroz commentedon Apr 28, 2015
You should use com.firebase.client.Firebase, check the docs of the API
jay3dec commentedon Apr 28, 2015
@leandroz That's in a native android application that we include using
com.firebase.client.Firebase. It doesn't work in NativeScript. It's some other way. If you have tried and were successful using Firebase in NativeScript, post some working code or something for me to follow. Thanksenchev commentedon Apr 28, 2015
You need to specify both class name and namespace in NativeScipt app. For example:
com.firebase.client.Firebase.setAndroidContext(this)
jay3dec commentedon Apr 28, 2015
@enchev Thanks that was it :)
Merge pull request #83 from NativeScript/vchimev-rc
lock commentedon Aug 31, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.