eddyverbruggen / nativescript-plugin-firebase Goto Github PK
View Code? Open in Web Editor NEW:fire: NativeScript plugin for Firebase
Home Page: https://firebase.google.com
License: MIT License
:fire: NativeScript plugin for Firebase
Home Page: https://firebase.google.com
License: MIT License
Using the latest plugin version. The login procedure will redirect me to the Facebook login page in Safari. After I sign in and accept, it redirects me to a blank page. I can only tap on "Done" in the upper left corner and a popup will say "login cancelled".
I have added the necessary lines in info.plist as Facebook stated when creating the app. Firebase config has also Facebook auth enabled with the correct API key and such.
Any plans to implement the resetPassword() function?
As many may know, Google just revamped Firebase to include a lot of new features, and the old Firebase will be deprecated. Any chances that this can be updated to match the new Firebase?
I'm able to run NativeScript simple example. However, I am getting 'spawn gradle.bat ENOENT' when I'm trying to build a project with firebase plugin where multidex is enabled. Here is my build log:
This happened after I added nativescript-plugin-firebase to the project. All I did was:
"tns plugin add nativescript-plugin-firebase"
and then I added "GoogleService-Info.plist" file to platforms/android.
Then I added following lines to platforms/android/build.gradle:
in dependencies, added: "com.google.gms:google-services:3.0.0" and at the end of file "apply plugin: "com.google.gms.google-services""
Finally enabled Multidex by adding "multiDexEnabled true" in app.gradle.
Thanks!
P.S.: I asked the same question in nativescript-cli and thought it might be related to firebase plugin. That's why I'm posting it again in firebase plugin issues.
The plugin doesn't show no init error but no other function seems to be working properly
if i try to login i get
JS: There was an exception while connecting to the authentication server: Host is unresolved: auth.firebase.com
after creating a listener it show the log that it was created but i'm not able to retrieve data
firebase.addChildEventListener added
using the push function only generates an id
This appears on Android
nativescript-plugin-firebase version : 2.1.1
CLI: 1.7.0
Cross-platform modules: 1.7.0
Runtime(s): 1.7.0
Hey there
After adding the nativescript firebase plugin using tns plugin add nativescript-plugin-firebase
, when I run tns run ios --emulator
the first time it works fine, but every following time, I get:
Found peer TypeScript 1.8.2
Expected "/*", "//" or "{" but "<" found.
Clearing out the platforms folder does the trick, but it also breaks livesync which is a real shame. Am I missing something obvious here?
Hope, i don't bother you with too simple question.
With the firebase.js library, I can get the full path to the new object, including the key at the end
For example
function createNode(myref, title, owner) {
return myref.push({ title : title, owner : owner});
}
...
mypath = createNode (myurl, "foo", "paul");
mykey = mypath.ref().
How can I get the new generated key with the plugin ?
function CreateNode(myref, title, owner) {
result = firebase.push(myref, { title : title, owner : owner});
return result;
}
result seems to be void (the push is correctly done)
Regards,
support for multi-location update should be available. this is an important feature for this plugin. would this be possible?
Sadly, the instructions for Android installation within a NativeScript app built using Angular don't work as the app structure is different when you create an Android app. For one thing, there's no app.gradle file in app/App_Resources/Android in this type of app. I try to build, but we get all kind of errors. could you take a look at the angular-firebase branch here: http://www.github.com/nativescript/sample-Groceries
thanks!
Due to the fact that resetPassword
creates a temporary password, the user must change its password manually from the client using changepassword
.
This plugin provides resetPassword
but not changepassword
.
How can i change the user's password using your plugin ?
I added the firbase plugin into my app.
I initially had this error:
:transformClassesWithDexForF0F1F2Debug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
So I tried to fix it with the following code from this link (NativeScript/android#344):
android {
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
But, then, I get this error...
:transformClassesWithDexForF0F1F2Debug
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.android.dx.cf.code.LocalVariableList.set(LocalVariableList.java:147)
at com.android.dx.cf.direct.StdAttributeFactory.parseLocalVariables(StdAttributeFactory.java:586)
at com.android.dx.cf.direct.StdAttributeFactory.localVariableTable(StdAttributeFactory.java:517)
at com.android.dx.cf.direct.StdAttributeFactory.parse0(StdAttributeFactory.java:178)
at com.android.dx.cf.direct.AttributeFactory.parse(AttributeFactory.java:96)
at com.android.dx.cf.direct.AttributeListParser.parse(AttributeListParser.java:141)
at com.android.dx.cf.direct.AttributeListParser.parseIfNecessary(AttributeListParser.java:115)
at com.android.dx.cf.direct.AttributeListParser.getList(AttributeListParser.java:106)
at com.android.dx.cf.direct.StdAttributeFactory.code(StdAttributeFactory.java:300)
at com.android.dx.cf.direct.StdAttributeFactory.parse0(StdAttributeFactory.java:139)
at com.android.dx.cf.direct.AttributeFactory.parse(AttributeFactory.java:96)
at com.android.dx.cf.direct.AttributeListParser.parse(AttributeListParser.java:141)
at com.android.dx.cf.direct.AttributeListParser.parseIfNecessary(AttributeListParser.java:115)
at com.android.dx.cf.direct.AttributeListParser.getEndOffset(AttributeListParser.java:96)
at com.android.dx.cf.direct.MemberListParser.parse(MemberListParser.java:213)
at com.android.dx.cf.direct.MemberListParser.parseIfNecessary(MemberListParser.java:108)
at com.android.dx.cf.direct.MethodListParser.getList(MethodListParser.java:54)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:542)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.parseClass(Main.java:764)
at com.android.dx.command.dexer.Main.access$1500(Main.java:85)
at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1684)
at com.android.dx.command.dexer.Main.processClass(Main.java:749)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:718)
at com.android.dx.command.dexer.Main.access$1200(Main.java:85)
at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1645)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
:transformClassesWithDexForF0F1F2Debug FAILED
FAILURE: Build failed with an exception.
By the way, I rebuild my android platform everytime I get an error, just in case.
For your information:
This is what my app.gradle looks like right now:
android {
defaultConfig {
applicationId "com.indoorcycling.android"
multiDexEnabled true
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Other files, like build.gradle, package.json, or google-services.json, look good.
How can I fix this error? It doesn't look so simple and seems like it requires some understanding of Android Native. Any help would be appreciated.
In a scenario where the plugin will be used in many views (many view modules) the plugin has to initialize for each module where it is included, isn't that right?
File firebase-common.js
line 26 has this:
var firebase = {};
// ...
firebase.instance = null;
But this firebase.instance
variable is not used anywhere in the code. Initialization for android has the following code for line 90:
firebase.init = function (arg) {
return new Promise(function (resolve, reject) {
try {
var Firebase = com.firebase.client.Firebase;
Firebase.setAndroidContext(appModule.android.context);
instance = new Firebase(arg.url);
resolve(instance);
} catch (ex) {
console.log("Error in firebase.init: " + ex);
reject(ex);
}
});
};
Therefore line 90 creates a new varible called instance
and pass it to the resolve()
function of the promise.
Is this the expected behavior? A user really has to init the firebase plugin for every module where it will be used? I assumed the firebase.instance
variable would be a module cached reference to the first initialization and that every module would use the same instance.
The code returns Promises... but the TyepScript definition says they don't. Simple fix in the firebase.d.ts file...
This plugin seens to have some issue with nativescript-admob. When using both, build fails.
:config phase: createDefaultIncludeFiles
+found plugins: nativescript-admob
+found plugins: nativescript-plugin-firebase
:config phase: createPluginsConfigFile
+creating product flavors include.gradle file in configurations folder...
:config phase: pluginExtend
+applying configuration from: /Users/macbook/Sites/testes/pass/platforms/android/configurations/include.gradle
+applying configuration from: /Users/macbook/Sites/testes/pass/platforms/android/configurations/nativescript-admob/include.gradle
+applying configuration from: /Users/macbook/Sites/testes/pass/platforms/android/configurations/nativescript-plugin-firebase/include.gradle
:config phase: copyAarDependencies
:config phase: addAarDependencies
+adding dependency: /Users/macbook/Sites/testes/pass/platforms/android/libs/aar/widgets-release.aar
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'pass'.
> No flavor is associated with flavor dimension 'nativescriptadmob'.
One more! We constantly are asked for support for hot push (e.g. deploying changes to the app stores without resubmitting), and it looks like Firebase Remote Config supports this. I would love to see this available for Firebase-configured apps!
Thanks!
It would be great to have support for Custom Authentication System as explained here:
Android:
https://firebase.google.com/docs/auth/android/custom-auth
Good job with this firebase plugin.
thank's for that.
But I'am facing an issue : I do a query to search for an item in the firebase path.
Here is my code
console.log('query start');
fbresp = firebase.query( function(snap) { console.log('query fired'); },
myPath,
{
orderBy: {type: firebase.QueryOrderByType.CHILD, value : 'title'},
range: {type: firebase.QueryRangeType.EQUAL_TO, value: 'foo' },
limit: {type: firebase.QueryLimitType.FIRST, value: 1 }
}
).then(
function () { console.log("firebase.query added"); },
function (error) { console.log("firebase.query error: " + error);
});
console.log('query end');
If "foo" exist in the firebase path, I see "query fired"
But if "foo" doesn't, I see nothing else that query start/query end
How can i know that an item is not in my database ?
In javascript, i use if (snap.exist()) {...
But here, the function where i could place this piece of code is not triggered.
regards
Stephane
TJ and I worked over our Groceries list for a while today, adding items to the array. We added an inverse time stamp to each element, hoping we could sort it so that when you add to a list, the item goes to the top. However, we don't see any logic to the way items are added, it's very strange. Sometimes they go to the top, sometimes elsewhere. We tried the various orderBy calls in the docs. Kind of strange!
https://github.com/NativeScript/sample-Groceries/blob/angular-firebase/app/shared/grocery/grocery-list.service.ts#L49-52 is our current query. We also tried 'Child' and 'Priority' but can't find a logic.
thanks!
Hi Guys! Thank you for excellent plugin - it's really useful. But I've got a problem:
I'm using fetch() in my project for make requests to some geo services. (google places, google geocoder, nominatim). And this method doesn't work with firebase plugin. For example, this code (url from nominatim wiki) must show me in console json response:
fetch("http://nominatim.openstreetmap.org/search/Unter%20den%20Linden%201%20Berlin?format=json&addressdetails=1&limit=1&polygon_svg=1")
.then(function(response) {
return response.json();
}).then(function(data) {
console.log("##############################")
console.log("###=" + JSON.stringify(data))
console.log("##############################")
});
and I've got nothing if I add firebase in my project or if I add this code in firebase demo project. Need help! Thanks.
P.S.
With http.getJSON() the same situation.
var http = require("http");
http.getJSON("http://nominatim.openstreetmap.org/search/Unter%20den%20Linden%201%20Berlin?format=json&addressdetails=1&limit=1&polygon_svg=1").then(function (data) {
console.log("##############################")
console.log("###=" + JSON.stringify(data))
console.log("##############################")
}, function (e) {
console.log(e);
});
I got the demo to work, but when adding this plugin to angular2-seed-advanced I keep getting this error:
JS: Error in firebase.init: TypeError: Cannot read property 'firebase' of undefined
JS: firebase.init error: TypeError: Cannot read property 'firebase' of undefined
Here's my code:
// 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({
selector: 'sd-home',
templateUrl: './app/components/home/home.component.html',
styleUrls: ['./app/components/home/home.component.css']
})
export class HomeComponent {
public newName: string = '';
public count: number = 0;
constructor(private store: Store<any>, public nameListService: NameListService) {
firebase.init({
url: 'https://ng2-test-107d1.firebaseio.com/',
persist: true
}).then((instance: any) => {
firebase.query((result: any) => {
this.count = result.value;
}, 'nativescript', { singleEvent: true });
}, function (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;
}
addOne(): void {
firebase.setValue('/nativescript', this.count++);
}
}
What am I missing?
Thanks @EddyVerbruggen for your work, how do we pass a Query to Firebase?
I am attempting to use this plugin, however I receive an error message when trying to log in. I have enabled Email & Password Authentication within the Firebase App Dashboard, so I don't think the issue is with that. Below is the code that I am using to log in. My idea is that loginType
is undefined, as I know firebase is defined as the init()
function works correctly.
firebase.login({
type: firebase.loginType.PASSWORD,
email: email.text,
password: password.text
}).then(
function(response){
for (i in response){
console.log(i + " || " + response[i])
}
}
)
I'm using this plugin in my new Nativescript project & getting following 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
Here is the link of my Stackoverflow post : http://stackoverflow.com/questions/37565864/typeerror-cannot-read-property-firebase-of-undefined-in-nativescript-app
As, totally new to both NativeScript & TypeScript I can't able to understand how to solve it.
According to the Firebase docs, you can set up Offline capabilities for your database like thus: https://firebase.google.com/docs/database/web/offline-capabilities
https://firebase.google.com/docs/database/android/offline-capabilities
We already have the ability to set the Persistence (setPersistenceEnabled) I believe; we just would need to use the keepSynched flag and handle data sync on the client side. A nice enhancement!
thanks!
Jen
I know push is a big fat pain but I feel like, by leveraging Firebase, we can avoid at least two or three extra plugin installations by supporting the build-in power of Firebase 3.0. Just want to put on your radar screen support for the new Firebase Cloud Messaging which is essentially rebranded GCM. Maybe we could reuse some GCM integration borrowed from the current NativeScript Push plugin.
Thanks Eddy!
Firebase has released SDK 2.5.0 for Android and iOS. We're at 2.4.x, so let's upgrade!
would it be possible to extend this plugin to support uploading larger documents, like music files? Asking for a friend 👯
firebase.ios.js, this function: "firebase.toJsObject ", cannot return correct Array, here is the JSON content:
{
"seqNo": 1,
"q": "Please tell me that you love NativeScript or not ? ",
"a_list": [
{
"key": "yes",
"value": "Yep, Pretty Sure."
},
{
"key": "no",
"value": "No"
}
],
"c_a": "yes"
},
When run in IOS emulator, step into the "toJsObject" function, cannot return correct "a_list"( in the JSON sample ), the reason is that( I comment it below :)
for (i = 0, l = oKeyArr.count; i < l; i++) {
key = oKeyArr.objectAtIndex(i);
var val = objCObj.valueForKey(key);
// when key === "a_list", the "types.getClass(val)" return is "NSMutableArray" which not match any
// case option, then just "miss/ignore it", any idea for fix this please, I don't familiar Object-C...:(
//
switch (types.getClass(val)) {
case 'NSMutableDictionary':
node[key] = firebase.toJsObject(val);
break;
case 'String':
node[key] = String(val);
break;
case 'Boolean':
node[key] = Boolean(String(val));
break;
case 'Number':
node[key] = Number(String(val));
break;
}
}
I have shown that a project cloned from git (samples-Groceries) builds and runs correctly on a connected device.
If I now add nativescript-plugin-firebase, the project fails to build.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'c:\Users\Mike\AppData\Local\Android\android-sdk\build-tools\23.0.1\aapt.exe'' finished with non-zero exit value 1
I have noticed a similar error occurring when I attempt to combine nativescript-geolocation and nativescript-google-sdk.
Removal of nativescript-plugin-firebase permits a successful build of the project.
System information:
{ procInfo: 'nativescript/1.5.2',
platform: 'win32',
os: 'Windows 10 Pro 6.3.10586',
shell: 'C:\WINDOWS\system32\cmd.exe',
dotNetVer: '4.6.01038',
procArch: 'x64',
nodeVer: 'v4.2.6',
npmVer: '2.14.12',
javaVer: '1.8.0',
nodeGypVer: null,
xcodeVer: null,
itunesInstalled: true,
cocoapodVer: null,
adbVer: 'Android Debug Bridge version 1.0.32',
androidInstalled: true,
monoVer: null,
gitVer: '2.7.0.windows.1',
gradleVer: null,
javacVersion: '1.8.0_72' }
Can we get a TypeScript definition?
Would be nice if we can create a user by passing in email and password.
Hi eddy, great plugins. I tried Removeeventlistener by calling into the firebase and it only works for 1 event listener for example if we have event listener for value and child. And for the 2nd remove event listener native script will crash
Do you have experiences about this? In ios works great and in ios just one call to remove listener but in android must call multiple remove listener
Thanks
From @wisonye on January 14, 2016 8:58
Before I upgrade to IOS 9.2( XCode 7.2 ), everything is fine, but my Iphone upgrade to IOS9.2, then I also update to new XCode, after I upgraded, seems some plugins not work, for example "firebase", right now cannot run, the error looks like this:
=== BUILD TARGET NativeScriptProject OF PROJECT NativeScriptProject WITH CONFIGURATION Debug ===
Check dependencies
CodeSign error: entitlements are required for product type 'Application' in SDK 'Simulator - iOS 9.2'. Your Xcode installation may be damaged.
** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
Command xcodebuild failed with exit code 65
# run ios
If I remove the plugin it can open fine( but of course my app will crash when running the firebase part ):
tns plugin remove nativescript-plugin-firebase
I've already modified the Pod file to use latest version of firebase( 2.5.0 ), still not work, any help on this :(
Copied from original issue: NativeScript/NativeScript#1372
First of all 👍 for this very useful plugin.
I noticed that, full library of google play service is included as dependency in platforms/android/include.gradle
file and due to this, the compile time is getting increased of the app and getting error of DexIndexOverflowException. (I know we have solution now of adding multiDexEnabled true
)
I tried to compile the project after removing compile "com.google.android.gms:play-services:9.0.0"
from include.gradle
(after removing android platform and then re-adding android platform), and the firebase functionalities are working without any issue.
So my question is, do we require full library of google play service as dependency in our app and if we require it, can we add only the required google play service api as dependency to reduce compile time?
You can check all the apis of google play service from here: https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project
Hi.
I am having a trouble running the angular-firebase branch of sample-groceries (https://github.com/NativeScript/sample-Groceries/tree/angular-firebase). I checked out these two issues (#36 and #48), but I still cannot get it working.
By the way, I also posted an issue here too (NativeScript/sample-Groceries#104). If this is a problem, please let me know
This is what the console looks like:
Successfully deployed on device with identifier 'ff144bbb'. 06-20 01:18:57.413 26107 26107 V GoogleSignatureVerifier: dxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjA JS: firebase.init done JS: Page loaded JS: BOOTSTRAPPING... JS: Setting DOM JS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode. JS: ANGULAR BOOTSTRAP DONE. chromium: [INFO:library_loader_hooks.cc(144)] Chromium logging enabled: level = 0, default verbosity = 0 06-20 01:19:15.333 26577 26577 I cr_BrowserStartup: Initializing chromium process, singleProcess=true JS: Error in firebase.init: Error: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist. JS: com.google.firebase.FirebaseApp.getInstance(Unknown Source) JS: com.google.firebase.FirebaseApp.getInstance(Unknown Source) JS: com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source) JS: com.tns.Runtime.runModule(Native Method) JS: com.tns.Runtime.runModule(Runtime.java:241) JS: com.tns.Runtime.run(Runtime.java:235) JS: com.tns.RuntimeHelper.initRuntime(RuntimeHelper.java:129) JS: com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:13) JS: android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1036) JS: android.app.ActivityThread.handleBindApplication(ActivityThread.java:6316) JS: android.app.ActivityThread.access$1800(ActivityThread.java:221) JS: android.app.ActivityThread$H.handleMessage(ActivityThread.java:1860) JS: android.os.Handler.dispatchMessage(Handler.java:102) JS: android.os.Looper.loop(Looper.java:158) JS: android.app.ActivityThread.main(ActivityThread.java:7224) JS: java.lang.reflect.Method.invoke(Native Method) JS: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) JS: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) JS: firebase.init error: Error: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist. JS: com.google.firebase.FirebaseApp.getInstance(Unknown Source) JS: com.google.firebase.FirebaseApp.getInstance(Unknown Source) JS: com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source) JS: com.tns.Runtime.runModule(Native Method) JS: com.tns.Runtime.runModule(Runtime.java:241) JS: com.tns.Runtime.run(Runtime.java:235) JS: com.tns.RuntimeHelper.initRuntime(RuntimeHelper.java:129) JS: com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:13) JS: android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1036) JS: android.app.ActivityThread.handleBindApplication(ActivityThread.java:6316) JS: android.app.ActivityThread.access$1800(ActivityThread.java:221) JS: android.app.ActivityThread$H.handleMessage(ActivityThread.java:1860) JS: android.os.Handler.dispatchMessage(Handler.java:102) JS: android.os.Looper.loop(Looper.java:158) JS: android.app.ActivityThread.main(ActivityThread.java:7224) JS: java.lang.reflect.Method.invoke(Native Method) JS: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) JS: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 06-20 01:19:21.413 26651 26651 V GoogleSignatureVerifier: dxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjA
When I try to do the sign up, I get this:
JS: --- auth state changed: com.google.android.gms.internal.zzadg@56469be JS: --- user: null JS: Logging in the user failed JS: Error: JS: Permission denied JS: --- auth state changed: com.google.android.gms.internal.zzadg@56469be JS: --- user: null JS: Logging in the user failed JS: Error: JS: Permission denied
How can I fix this?
The following information may be redundant, but I'll post them anyways just in case.
app.gradle
android { defaultConfig { applicationId "org.nativescript.groceries" multiDexEnabled true generatedDensities = [] } aaptOptions { additionalParameters "--no-version-vectors" } }
package.json
{ "name": "Groceries", "version": "1.0.0", "description": "A NativeScript-built iOS and Android app for managing grocery lists", "repository": { "type": "git", "url": "https://github.com/nativescript/sample-Groceries.git" }, "keywords": [ "NativeScript" ], "author": "TJ VanToll <[email protected]> (https://www.tjvantoll.com/)", "license": "MIT", "bugs": { "url": "https://github.com/nativescript/sample-Groceries/issues" }, "homepage": "https://github.com/nativescript/sample-Groceries/groceries", "nativescript": { "id": "org.nativescript.groceries", "tns-ios": { "version": "2.0.1" }, "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", "email-validator": "^1.0.4", "nativescript-angular": "0.1.6", "nativescript-iqkeyboardmanager": "^1.0.1", "nativescript-plugin-firebase": "^3.0.1", "nativescript-social-share": "^1.1.3", "nativescript-unit-test-runner": "^0.3.3", "tns-core-modules": "2.0.0-angular-7" }, "devDependencies": { "babel-traverse": "6.9.0", "babel-types": "6.10.0", "babylon": "6.8.1", "filewalker": "0.1.2", "jasmine-core": "^2.4.1", "karma": "^0.13.22", "karma-jasmine": "^1.0.2", "karma-nativescript-launcher": "^0.4.0", "lazy": "1.0.11", "nativescript-dev-typescript": "^0.3.2", "typescript": "^1.8.10" } }
build.gradle
`
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:1.5.0"
classpath 'com.google.gms:google-services:3.0.0'
}
}
apply plugin: 'com.google.gms.google-services'
`
google-services.json
{ "project_info": { "project_number": "1029306009568", "firebase_url": "https://test-fd26c.firebaseio.com", "project_id": "test-fd26c", "storage_bucket": "test-fd26c.appspot.com" }, "client": [ { "client_info": { "mobilesdk_app_id": "**********************************************", "android_client_info": { "package_name": "org.nativescript.groceries" } }, "oauth_client": [ { "client_id": "**********************************************", "client_type": 3 } ], "api_key": [ { "current_key": "**********************************************" } ], "services": { "analytics_service": { "status": 1 }, "appinvite_service": { "status": 1, "other_platform_oauth_client": [] }, "ads_service": { "status": 2 } } } ], "configuration_version": "1" }
Any help would be really appreciated. Thank a lot in advance.
@EddyVerbruggen, First of all, thanks for this nice plugin. Currently, I'm using this in one my android app & I'm having some strange behavior.
Whenever I'm using createUser
method for creating a new user account in response I'm getting KEY(User UID) of the just immediate user which I'd created before this. Here is my testing flow -
I'd a small chat with #jacosta in NativeSscript slack channel about this. He suggested me to use logout
method(which I'm currently not using) to log out old user & then user createUser
method to create new user account. Although, I've not tested this one yet now but I think it's kind issue.
I am initializing the firebase instance like this. I get "Firebase is ready!". So I suppose, it is all good.
ngOnInit() {
console.log("sdfdsf");
firebase.init({
url: 'https://COOLDBURL.firebaseio.com/',
persist: true
}).then(
(result)=> {
dialogs.alert({
title: "Firebase is ready",
okButtonText: "Merci!"
});
},
(error) => {
console.log("firebase.init error: " + error);
}
);
}
this works
firebase(){
firebase.setValue(
'/companies',
{'foo':'bar'}
);
// to store an array of JSON objects
firebase.setValue(
'/companies',
[
{name: 'Telerik', country: 'Bulgaria'},
{name: 'Google', country: 'USA'}
]
);
}
this does not work
firebase(){
firebase.createUser({
email: '[email protected]',
password: 'firebase'
}).then(
function (result) {
dialogs.alert({
title: "User created",
message: "userid: " + result.key,
okButtonText: "Nice!"
})
},
function (errorMessage) {
dialogs.alert({
title: "No user created",
message: errorMessage,
okButtonText: "OK, got it"
})
}
)
}
I get the following error, if i want to build it for android:
`:buildMetadata
Exception in thread "main" java.lang.IllegalArgumentException: Class com.tns.internal.AppBuilderCallback conflict: /Users/mschakulat/stuff/nativescript/myapp/platforms/android/build/intermediates/classes/F0F1/debug and /Users/mschakulat/stuff/nativescript/myapp/platforms/android/build/intermediates/classes/F0/debug
at com.telerik.metadata.ClassRepo.cacheJarFile(ClassRepo.java:21)
at com.telerik.metadata.Builder.build(Builder.java:42)
at com.telerik.metadata.Generator.main(Generator.java:44)
:buildMetadata FAILED
FAILURE: Build failed with an exception.
Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
`
Currently working on the iOS implementation. It's not trivial but I will pull through!
I've been working on solving this myself for 2 days but to no avail. No matter what I do, I cannot get past this error in my Nativescript 2/Angular 2 app.
classpath "com.google.gms:google-services:3.0.0"
and apply plugin: "com.google.gms.google-services"
in my build.gradle.Despite all of this, the error persists. I tried upping com.google.firebase:firebase-database
and com.google.firebase:firebase-auth
to 9.0.2, but that didn't help either. My application always builds and runs perfectly, but then this error. For reference, I am initializing firebase in my main.ts before nativeScriptBootstrap is called.
Do you have any ideas? I'm happy to supply whatever config files may help.
JS: Error in firebase.init: Error: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
JS: com.google.firebase.FirebaseApp.getInstance(Unknown Source)
JS: com.google.firebase.FirebaseApp.getInstance(Unknown Source)
JS: com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
JS: com.tns.Runtime.runModule(Native Method)
JS: com.tns.Runtime.runModule(Runtime.java:241)
JS: com.tns.Runtime.run(Runtime.java:235)
JS: com.tns.RuntimeHelper.initRuntime(RuntimeHelper.java:129)
JS: com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:13)
JS: android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
JS: android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
JS: android.app.ActivityThread.-wrap1(ActivityThread.java)
JS: android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
JS: android.os.Handler.dispatchMessage(Handler.java:102)
JS: android.os.Looper.loop(Looper.java:148)
JS: android.app.ActivityThread.main(ActivityThread.java:5417)
JS: java.lang.reflect.Method.invoke(Native Method)
JS: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
JS: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
JS: firebase.init error: Error: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
JS: com.google.firebase.FirebaseApp.getInstance(Unknown Source)
JS: com.google.firebase.FirebaseApp.getInstance(Unknown Source)
JS: com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
JS: com.tns.Runtime.runModule(Native Method)
JS: com.tns.Runtime.runModule(Runtime.java:241)
JS: com.tns.Runtime.run(Runtime.java:235)
JS: com.tns.RuntimeHelper.initRuntime(RuntimeHelper.java:129)
JS: com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:13)
JS: android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
JS: android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
JS: android.app.ActivityThread.-wrap1(ActivityThread.java)
JS: android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
JS: android.os.Handler.dispatchMessage(Handler.java:102)
JS: android.os.Looper.loop(Looper.java:148)
JS: android.app.ActivityThread.main(ActivityThread.java:5417)
JS: java.lang.reflect.Method.invoke(Native Method)
JS: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
JS: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Hi Guys,
I have been trying to make this plugin to work in my project, but I am stuck with this error:
V/JS (32145): firebase.init error: Error: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
V/JS (32145): com.google.firebase.FirebaseApp.getInstance(Unknown Source)
V/JS (32145): com.google.firebase.FirebaseApp.getInstance(Unknown Source)
V/JS (32145): com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
V/JS (32145): com.tns.Runtime.callJSMethodNative(Native Method)
V/JS (32145): com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
V/JS (32145): com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
V/JS (32145): com.tns.Runtime.callJSMethod(Runtime.java:712)
V/JS (32145): com.tns.Runtime.callJSMethod(Runtime.java:693)
V/JS (32145): com.tns.Runtime.callJSMethod(Runtime.java:683)
V/JS (32145): com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:13)
V/JS (32145): android.app.Activity.performCreate(Activity.java:6021)
V/JS (32145): android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
V/JS (32145): android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
V/JS (32145): android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
V/JS (32145): android.app.ActivityThread.access$800(ActivityThread.java:155)
V/JS (32145): android.app.ActivityThread$H.handleMessage(ActivityThread.java:1323)
V/JS (32145): android.os.Handler.dispatchMessage(Handler.java:102)
V/JS (32145): android.os.Looper.loop(Looper.java:135)
V/JS (32145): android.app.ActivityThread.main(ActivityThread.java:5376)
V/JS (32145): java.lang.reflect.Method.invoke(Native Method)
V/JS (32145): java.lang.reflect.Method.invoke(Method.java:372)
V/JS (32145): com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
V/JS (32145): com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
This is my service that consumes the nativescript-plugin-firebase API (that's what's on the other side of the FIREBASE
token), and the push
inside addChild
resolves, but no data is written in firebase.
import {Injectable, Inject} from '@angular/core';
import {FIREBASE} from '../../../app/frameworks/core.framework/index'
@Injectable()
export class NSDatabaseService {
private database:any;
private onSync:Function;
private userID:string;
constructor(@Inject(FIREBASE) firebase:any) {
console.log('Constructing NSDatabaseService');
this.database = firebase;
this.database.init({
persist: true // Allow disk persistence. Default false.
}).then((instance:any) => {
console.log('firebase.init successful');
}, (error:any) => {
console.log('firebase.init error: ' + error);
});
}
sync(path: string, onValueReceived: Function):void {
this.onSync = (result:any) => onValueReceived(result.value);
this.database.addValueEventListener(this.onSync, path);
}
addChild(path:string, data:any, callback?:Function):void {
this.database.push(path, data).then(function (result:any) {
console.log('created key: ' + result.key);
if (callback) {
callback(result.key)
}
});
}
}
Note that it works on the iOS emulator.
Here is my setup.
Enviroment
Windows 7 64bits
Genymotion android 4.4
Genymotion Google play service setup
Create new Nativescript app
Install [email protected]
defaultConfig {
generatedDensities = []
applicationId “org.nativescript.myapp”
multiDexEnabled true
}
dependencies {
classpath “com.android.tools.build:gradle:1.5.0”
classpath “com.google.gms:google-services:3.0.0”
}
/// <reference path=”../node_modules/nativescript-plugin-firebase/firebase.d.ts” />
/// <reference path=”../node_modules/nativescript-plugin-firebase/firebase-common.d.ts” />
var application = require(“application”);
var firebase = require(“nativescript-plugin-firebase”);
firebase.init({
persist: true // Allow disk persistence. Default false.
}).then(function (instance) {
console.log(“firebase.init done”);
},function (error) {
console.log(“firebase.init error: “ + error);
});
application.start({ moduleName: “main-page” });
Ok, app is running but got firebase init error: cannot read property firebase of undefined in cmd.
After adding this plugin to a new nativescript appbuilder project via properties -> dependencies -> install from plugins marketplace I get an error when trying to require.
var firebase = require("nativescript-plugin-firebase");
Error: Module "nativescript-plugin-firebase" not found
File: "/data/data/com.telerik.NativeScript/files/app/
components/homeView/homeView.js
Hi,
In my Firebase database, I have this:
{
"deals": {
"_1234567890": {...}
}
}
If I run this code, I receive nothing from the onQueryEvent
:
var onQueryEvent = function(result) {
console.dump(result);
if(!result.error) {
console.log("Event type: " + result.type);
console.log("Key: " + result.key);
console.log("Value: ");
console.dump(result.value);
}
};
firebase.query(onQueryEvent, "/deals", {
singleEvent: true,
orderBy: {
type: firebase.QueryOrderByType.KEY
}
});
result seems to be null
or undefined
as well, so it doesn't hand me any error. Nothing is being logged in other words. What am I doing wrong?
Another opportunity to reduce the amount of plugins installed would be the ability to use Firebase's built-in AdMob integration. Seems like a great opportunity to augment a three-in-one plugin install.
thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.