Setup your Firebase
Setting up Firebase Project
To use FCM, you need a Google account to log in to the Firebase Console.
-
After logging in to the Firebase console, click "Getting started" where you will be taken to a page to create a project.
-
Create a project that you will use to utilize Firebase by clicking create project:
- Enter the name of project and accept Firebase terms
- Select to enable or disable Google Analytics depending on your preference
- Depending on your previous choice you will be prompted to go to your project, or to agree to terms for using Google Analytics then prompted to go to your project.
-
Create a Firebase app for either
- Android
- iOS
- or both
Android Firebase Setup
-
Click on the Android icon below the Get started by adding Firebase to your project statement.
-
Register app name by adding the Android package name.
-
Download the google-services.json file and add the file to the project.
-
Add Firebase SDK to your project
Project-level build.gradle (PROJECTNAME/build.gradle):
buildscript {repositories {// Check that you have the following line (if not, add it):google() // Google's Maven repository}dependencies {...// Add this lineclasspath 'com.google.gms:google-services:4.3.10'}}allprojects {...repositories {// Check that you have the following line (if not, add it):google() // Google's Maven repository...}}- Continue to console.
iOS Firebase Setup
-
Click on the iOS icon after selecting add app
-
Register app name by adding the iOS bundle ID.
-
Download the GoogleService-Info.plist file and add the file to the project.
-
Add Firebase SDK to your project
Google services use CocoaPods to install and manage dependencies. Open a terminal window and navigate to the location of the Xcode project for your app.
Create a Podfile if you don't have one:
$ pod initOpen your Podfile and add:
# add pods for desired Firebase products# https://firebase.google.com/docs/push-notifications/ios/setup#available-podsSave the file and run:
$ pod installThis creates an
.xcworkspacefile for your app. Use this file for all future development on your application. -
Add initialisation code
To connect Firebase when your app starts up, add the initialisation code below to your
AppDelegate.mfile.@import UIKit;@import Firebase;@implementation AppDelegate- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[FIRApp configure];return YES;}Add APNs Certificate to Firebase Cloud Messaging
In the Project Overview from the Firebase Console of your Project:
- Read the guide to obtain an APNs Certificate. Skip this step if you already have one.
- Go to Project Settings
- Go to Cloud Messaging (Tab)
- On iOS app configuration -> APNs Authentication Key -> Click Upload
- Add the Certificate APNs you have generated
Getting App Keys and App Messenger Id
To obtain the Server Key and Sender ID. Go to:
- On the sidebar next to project overview there is a setting icon with a collapsible list.
- Select Project setting
- Select the Cloud Messaging tab to get the Server Key and Sender ID.
- Copy the Server Key and Sender ID that you will use to configure the BILDIT Visual Experience Engine Firebase push feature or set up an OneSignal account.