leoho0722
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee
  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    ###### tags: `第13屆IT邦鐵人賽文章` # 【在 iOS 開發路上的大小事-Day13】Firebase 你好啊! # 前情提要 Firebase 是 Google 推出的雲端後端服務平台,提供了行動端 (Android / iOS) 及網頁端 (Web) 的應用服務,擁有即時資料、低維護成本等特色,此外也提供了多種後端服務 (如:驗證服務、資料庫服務、數據分析服務、推播通知服務等) ![](https://i.imgur.com/HsYpTLC.png) [Firebase iOS 開發文檔 (點我)](https://firebase.google.com/docs/ios/setup) # 開始安裝 Firebase 到專案內囉 Firebase 有提供下面這幾種方式可以將其安裝到專案內 1. CocoaPods (官方推薦) 2. 集成 SDK 框架 3. Swift Package Manager 這邊我選擇使用 CocoaPods 來進行安裝 先用 Terminal 切換到專案目錄底下 接著再打開專案內的 Podfile,將你需要用到的 Firebase 服務增加進去 這裡我先將 Firebase 的基本框架新增進去,後面幾天所需要的服務,等到時候再一一添加進來 如果不知道要怎麼加入對應的服務,可以參考[開發文檔底下的說明](https://firebase.google.com/docs/ios/setup#available-pods) ``` pod 'Firebase/Core' ``` ![](https://i.imgur.com/eVTrSca.png) 接著在 Terminal 輸入安裝指令 ``` pod install ``` ![](https://i.imgur.com/nvFKJA3.png) 這樣就算安裝完成了,接著在開啟 `專案名稱.xcworkspace` 切換到 AppDelegate.swift 在最上面引入 Firebase ```swift= import Firebase ``` 在 AppDelegate.swift 裡的「didFinishLaunchingWithOptions」加入下面這一行 ```swift= func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { FirebaseApp.configure() // 加入這一行 return true } ``` # 到 Firebase Console 設定 打開 [Firebase Console](https://console.firebase.google.com/u/3/),新建一個專案 ![](https://i.imgur.com/5uYjw7m.png) 輸入在 Firebase 的專案名稱 這邊我是取跟 Xcode 專案相同的名稱,這樣會比較好找 ![](https://i.imgur.com/AfjMHKK.png) Firebase 的 Google Analytics 就按繼續 ![](https://i.imgur.com/15GsGaH.png) 設定 Google Analytics 的帳戶,這邊我是跟 Firebase 專案用相同帳戶 ![](https://i.imgur.com/jFd6W3W.png) 接著就可以按下建立專案了,等他跑完,專案就建立好了 建立好之後,就會看到這個 Firebase 專案的後台了 ![](https://i.imgur.com/3xL0txa.png) 點擊畫面中間的 iOS,來將我們的 App 跟 Firebase 連在一起 ![](https://i.imgur.com/aNtLrL2.png) 接著就是把 Xcode 專案的 Bundle Identifier 新增到 Firebase 專案內,填好之後,就按下註冊應用程式 ![](https://i.imgur.com/omNe9JH.png) 接著就照著圖上的指示做就可以了,要注意的是 GoogleService-Info.plist 不要外流,因為這相當是等於專案的 Key,在做 Git 版本控制的時候要注意 ![](https://i.imgur.com/HNR4jG2.png) 第三步是將 Firebase SDK 新增到專案內,這部分前面我們已經做好了,所以就可以略過 ![](https://i.imgur.com/oc8ybej.png) 第四步是在 AppDelegate.swift 裡新增初始化 Code,這部分前面我們也已經做好了,所以就略過 ![](https://i.imgur.com/Y1Wplgm.png) 這樣在 Firebase Console 就算設定完成了 後面幾天,會來分享如何透過 Firebase 來實作登入登出、第三方帳號登入、資料庫服務

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully