Firebase Database setup

27 篇文章 0 订阅

Installation & Setup on iOS

The Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON and synchronized in realtime to every connected client. When you build cross-platform apps with our Android, iOS, and JavaScript SDKs, all of your clients share one Realtime Database instance and automatically receive updates with the newest data.

Prerequisites

  1. Install the Firebase SDK.
  2. Add your app to your Firebase project in the Firebase console.
Note:  Our SDKs have changed. If you are upgrading from a 2.X version of the Firebase SDK, please read our upgrade guide for iOS.

Add Firebase Realtime Database to your app

Ensure the following dependency is in your project's Podfile:

 
 
pod 'Firebase/Database'

Run pod install and open the created .xcworkspace file.

Configure Firebase Database Rules

The Realtime Database provides a declarative rules language that allows you to define how your data should be structured, how it should be indexed, and when your data can be read from and written to. By default, read and write access to your database is restricted so only authenticated users can read or write data. To get started without setting up Authentication, you can configure your rules for public access. This does make your database open to anyone, even people not using your app, so be sure to restrict your database again when you set up authentication.

Set up Firebase Realtime Database

You must initialize Firebase before any Firebase app reference is created or used. If you have already done this for another Firebase feature, you can skip this step.

  1. Import the Firebase module in your UIApplicationDelegate:
    SWIFT
    OBJECTIVE-C
     
        
    @import Firebase ;
  2. Configure a FirebaseApp shared instance, typically in your application's application:didFinishLaunchingWithOptions: method:
    SWIFT
    OBJECTIVE-C
     
        
    // Use Firebase library to configure APIs
    [ FIRApp configure ];

Once you've initialized Firebase Realtime Database, define and create a reference to your database as follows:

SWIFT

OBJECTIVE-C

 
  
@property ( strong , nonatomic ) FIRDatabaseReference * ref ;

self . ref = [[ FIRDatabase database ] reference ];

Prepare for Launch

Before launching your app, we recommend walking through our launch checklist to make sure your app is ready to go!

Next Steps

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值