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

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).

主站蜘蛛池模板: 安国市| 安塞县| 宿迁市| 苏州市| 玉屏| 日喀则市| 清涧县| 镇坪县| 广平县| 元谋县| 武城县| 宽甸| 石门县| 秦安县| 玉林市| 张掖市| 潜山县| 玛曲县| 陵川县| 永丰县| 永昌县| 革吉县| 屏东县| 涟水县| 渑池县| 玛沁县| 嵩明县| 吴旗县| 陵水| 舟山市| 汽车| 托克托县| 忻州市| 扎兰屯市| 彭水| 安西县| 新化县| 万山特区| 永兴县| 红桥区| 乐业县|