官术网_书友最值得收藏!

Setting up

Here's how we'll get going with Firebase:

  1. We'll go to the Firebase console.
  2. From there, we'll create a project.
  3. We'll name our lovely little project.
  4. We'll get the code necessary to integrate it into our app.
  5. We'll add that code to index.html.
  6. We'll make Firebase available as a global variable.

If you're ready to get started, let's do it:

  1. Once you've created or logged in to your Google account, head over to https://firebase.google.com/. In the top-right corner of your screen, you should see a button titled GO TO CONSOLE:
  1. From the Firebase console, we want to Add Project. Click on the icon:
  1. For Project Name, choose chatastrophe (all lowercase), and then select your Country/Region.
  2. Firebase should take you directly to the project page once that's done. From there, click on the link that says Add Firebase to your web app:
  1. Copy and paste the code it gives you into your public/index.html, before the closing </body> tag:
<body>
<div id="root"></div>
<script src="https://www.gstatic.com/firebasejs/4.1.2/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: /* API KEY HERE */,
authDomain: "chatastrophe-77bac.firebaseapp.com",
databaseURL: "https://chatastrophe-77bac.firebaseio.com",
projectId: "chatastrophe-77bac",
storageBucket: "chatastrophe-77bac.appspot.com",
messagingSenderId: "85734589405"
};
firebase.initializeApp(config);
</script>
</body>
  1. Lastly, we need to make our Firebase application available to the rest of our app. At the bottom of the script tag, just before the firebase.initializeApp(config) line, add the following:
window.firebase = firebase;

This code stores our Firebase setup on the window object, so we can access it in the rest of our JavaScript.

If you're not using source control (GitHub or Bitbucket, for example) or are using a private repository to store your code, you can skip to the next section. For the rest of us, we need to do some work to ensure that we don't display our config.apiKey to the entire world (a recipe for malicious use).

主站蜘蛛池模板: 芮城县| 罗源县| 海南省| 南充市| 云安县| 石台县| 乐亭县| 临泉县| 伊金霍洛旗| 麦盖提县| 徐水县| 邵阳县| 故城县| 宁乡县| 宣化县| 金坛市| 宝坻区| 阳春市| 大厂| 司法| 临汾市| 博兴县| 全南县| 洱源县| 和政县| 丹东市| 明光市| 大余县| 徐汇区| 青浦区| 浑源县| 铁岭县| 黄大仙区| 怀安县| 金山区| 阜新| 喀喇| 岐山县| 宁远县| 上林县| 盐城市|