Add Firebase Realtime Database to your app
Ensure the following dependencies are in your project's
pod 'Firebase/Core' pod 'Firebase/Database'
pod install and open the created
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 your
- Configure a
FirebaseAppshared instance, typically in your application's
// Use Firebase library to configure APIs FirebaseApp.configure()
// 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:
var ref: DatabaseReference! ref = Database.database().reference()
@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!
- 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.