-
Notifications
You must be signed in to change notification settings - Fork 274
Chat SDK iOS: Firebase Configuration
The Chat SDK relies on Firebase as a backend. Your Firebase account contains the database storing all the chat information, stored files, everything that allows the chat to function properly.
In this tutorial we are going to be focusing on Firebase set up as this is required for the initial migration of the ChatSDK into your custom app project. If you have not already completed the Chat SDK migration documentation we strongly recommend you reading it before starting this tutorial.
Before you start we recommend watching the following video which runs through the entire process. You can then work through with the step by step instructions below.
You first need to create a Firebase account with which to link with your project:
- Go to the Firebase website and create an account
- Create a new project on the dashboard
- Click on the project and then the database in the left hand menu
- Copy the URL at the top of your browser, it should look something like this:
https://yourappname.firebaseio.com/
- Modify your URL to be in the following format:
gs://yourappname.appspot.com
- Navigate to your project
Info.plist
, open thechat_sdk
dictionary and thefirebase
tab - Copy the modified URL into the
storage_path
field
Next you need to enter a root_path
, this can be anything. We recommend something like "V1" to get started. The root path is the path at which your ChatSDK data will be stored on Firebase.
The root path is a very strong feature of the ChatSDK data structure. It allows you to use a single Firebase database for multiple versions of your project. For example you could create a /live path and a /testing path. These are completely separate meaning when testing new features there is no chance of corrupting your current data model.
Note: Firebase's data structure is like a tree. Your storage URL is the trunk and the root path is the next split. From there we branch to store the information on threads, users, messages etc. You can read this article to understand further.
Next,
- Click on the cog icon at the top of the page in your project view in Firebase.
- Select Project settings
- Click Add app
- Enter your bundleID
- Ignore the rest of the instructions. These steps are talking about code required in your project but as we have added it already you can safely skip this.
- Navigate to the
GoogleService-Info.plist
which has been downloaded - Copy this file and add it to the project where you previously added the
BTwitterHelper
files (if you already have aGoogleService-Info.plist
file then delete it and replace it with your new one)
Note: It is worth opening your downloaded
GoogleService-Info.plist
and checking there is anAPI_KEY
field included. Sometimes the automatic download doesn't include this in the plist. To rectify this just re-download the plist from the project settings menu.
Now we need to update a few of the values from this newly downloaded plist.
- Open the
Info.plist
and then open the URL types row - Open up
Item 1 (Editor)
andItem 2 (Editor)
fully - Replace the
bundleID
inItem 1 (Editor)
->URL Schemes
->Item 0
with your projectbundleID
- Replace the google app code in
Item 2 (Editor)
->URL Schemes
->Item 0
with thereverse client ID
contained in theGoogleService-Info.plist
you just downloaded (open the downloaded plist and copy the reverse client ID field).
And that's it. If you load up your project and the ChatSDK will be ready to go.