Cannot Interact with RealtimeDB - Error "Run init First"
See original GitHub issueHi all,
Trying to get database working with this plugin. I have login abilities working, and I am able to create users and delete and what not.
However, when it comes to working with Firebase RealTimeDB, I cannot get it to interact at all.
I have followed all steps and go as far as removing my code and using the demo code and linking it to my database, however no luck.
I will “run init”, and will get a success message, however when I go to push or query the database, I get a “Error: run init” message.
I have attached code for reference, please let me know if you need anything else.
Kind Regards, Harrison
`var observableModule = require(“data/observable”); var dialogs = require(“ui/dialogs”); var utils = require(“utils/utils”); var fs = require(“file-system”); var firebase = require(“nativescript-plugin-firebase”); const firebaseWebApi = require(“nativescript-plugin-firebase/app”); var platform = require(“platform”);
function econtactFrmViewModel() { var viewModel = observableModule.fromObject({
});
viewModel.registerUser = function () {
firebase.push(
'/users',
{
'first': 'Eddy',
'last': 'Verbruggen',
'birthYear': 1977,
'isMale': true,
'address': {
'street': 'foostreet',
'number': 123
}
}
).then(
function (result) {
dialogs.alert({
title: "Working",
message: result.key,
okButtonText: "OK"
});
},
function (error) {
dialogs.alert({
title: "Login error",
message: error,
okButtonText: "OK, pity"
});
}
);
};
return viewModel;
}
module.exports = econtactFrmViewModel;`
`/* In NativeScript, the app.js file is the entry point to your application. You can use this file to perform app-level initialization, but the primary purpose of the file is to pass control to the app’s first module. */
require(“./bundle-config”); const application = require(“application”); const firebase = require(“nativescript-plugin-firebase/app”); firebase.init({ // Optionally pass in properties for database, authentication and cloud messaging, // see their respective docs. persist: true }).then(function (instance) { console.log(“firebase.init done”); }, function (error) { console.log("firebase.init error: " + error); });
application.run({ moduleName: “app-root” });
/* Do not place any code after the application has been started as it will not be executed on iOS. */ `
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
@devteam8BT did you find a fix for the issue? If you do can you share with us? I am having the same issue here.
Will do, just need to remove some files and resources due to IP.