-
Notifications
You must be signed in to change notification settings - Fork 611
Chat SDK Android: Firebase Configuration
Setting up Firebase for Android is similar to the set up required for iOS but with some notable differences.
- Go to the Firebase website and create an account if you don't already have one
- Create a new project on the dashboard
- Click on the project and then click database in the left hand menu
- Copy the URL from your browser, it should look something like:
https://yourappname.firebaseio.com/
- Modify the URL to be in the following format:
gs://yourappname.appspot.com
- Navigate to the
BDefines.java
file in your project.sdk
->java
->com
->braunster.chatsdk
->network
->BDefines
- Add your modified URL instead of the
FirebaseStoragePath
and the original URL as theServerUrl
It should look similar to this:
public static final String BRootPath = "testRoot/";
public static String ServerUrl = "https://your-firebase-name.firebaseio.com/" + BRootPath;
public static String FirebaseStoragePath = "gs://your-firebase-name.appspot.com";
Note: We recommend adding a trailing slash to the BRootPath and the ServerUrl as problems have sometimes occurred when this is left off.
Note: The root path allows you to split the database into different branches. The data and users in each branch will be completely separate from each other meaning you can change the root path for your testing and live versions.
Finally you need to create a JSON file for your app on Firebase
- Navigate to the Firebase website
- Click the cog icon and then click Project settings
- Click Add app
- Click the Android icon
- Add your App package ID
- The rest of the instructions are all already covered, finishing should download a Google Services JSON file
- Add this JSON file to your
sdk
file.
IMPORTANT: You need to go through this process twice. The second time you must add the below package name to allow Firebase to connect to your project: com.braunster.androidchatsdk.firebaseplugin
- Click the cog icon and then click Project settings
- Click Add app
- Click the Android icon
- Add the package:
com.braunster.androidchatsdk.firebaseplugin
- Download the JSON file
- Add the JSON file to your
firebase_plugin
folder
The Android Chat SDK is now completely configured with Firebase