0

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

Sylvain
  • 11
  • 3
  • Hi Sylvain. The image you link provided seems to be broken (well, initially at least). Instead of providing an image for your code, please post it as an actual formatted text. – AL. May 31 '17 at 09:03
  • Hi AL, I have updated with formated text, thanks for the advice – Sylvain May 31 '17 at 09:10
  • @Sylvain ,I am trying to Integrate Firebase Analytics for Rect Native App . This is Analytics is working fine in Web, Android and IOS . But Now , i ma running this App in TIzen . How can i Integrate Firebase Analytics Tizen Web App? – Murali V Jul 07 '22 at 04:36

1 Answers1

0

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.