I'm trying to request my firebase from a tizen web app. So I have added the firebase config to script section, then I need to access my firebase object from the javascript but I don't know how to proceed, how to declare 'firebase' variable to be linked to the firebase lib? here is my code :
tizen studio screenshot
or
function init() { // How to get firebase object ? firebase.database() .ref('/test') .once('value').then(function(snapshot) { var value = snapshot.val(); document.querySelector("#foo") .innerHTML = value; }); ... }
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <title>Hello Tizen</title> <link rel="stylesheet" href="css/style.css"> <script src="https://www.gstatic.com/firebasejs/4.0.0/firebase.js"></script> <script> // Initialize Firebase var config = { apiKey: "blabla", authDomain: "blabla", databaseURL: "blabla", projectId: "blabla", storageBucket: "blabla", messagingSenderId: "blabla" }; firebase.initializeApp(config); </script> </head> <body> <div id="container"> <div id="contents"> <span id="foo">To replace </span> </div> </div> <script src="js/app.js"></script> </body> </html>
EDIT :
adding <access origin="*" subdomains="true"></access>
to config.xml solve my internet connection issue
You seem to have forgotten to put these scripts as well
<script src="https://www.gstatic.com/firebasejs/4.0.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.0.0/firebase-database.js"></script>
firebase-app.js should always come first.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.