Firebase Database setup
2018-02-28 09:17
507 查看
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
Install the Firebase SDK.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'sPodfile:
pod 'Firebase/Database'Run
pod installand open the created
.xcworkspacefile.
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.Import the Firebase module in yourUIApplicationDelegate:
SWIFT
OBJECTIVE-C
@import Firebase;Configure a
FirebaseAppshared 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
Learn how to structure data for Realtime Database.Scale your data across multiple database instances.
Read and write data.
View your database in the Firebase console.
相关文章推荐
- [React Native + Firebase] React Native: Real time database with Firebase -- setup & CRUD
- [Firebase] 4. Firebase Object related Database
- [AngularFire 2] Object Observables - How to Read Objects from a Firebase Database?
- firestore vs firebase database
- understanding firebase database billing
- Android 集成FireBase Realtime DataBase实现聊天
- [Angular] Setup automated deployment with Angular, Travis and Firebase
- firebase database limit
- best practice of data structure of firebase database
- 拥抱Firebase,Firebase之Realtime Database。(含github源码),欢迎关注。
- Firebase Database Structure
- understand firebase realtime database rules
- firebase database read and write
- firebase database: secure your data
- firebase database - work with lists
- firebase database: user based security
- firebase database - offline access
- firebase database: index your data
- firebase database: scale with multiple databases
- firebase database: Extend realtime database with cloud functions