fcm-service
Firebase Cloud Messaging
Firebase Cloud Messaging (FCM) is a service from firebase. Firebase is a platform that got acquired by Google and has a healthy and active community. Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably send messages and can transfer a payload of up to 4000 bytes to a client app.
Setting up Firebase Project
For one to use FCM one need a google account to login to the Firebase Console.
After login to 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 the firebase by clicking create projec
- Enter name of project and accept firebase terms
- Select to enable google analytics or disable depending on your preference
- Depending on your previos choice you will be propmted to go to your project, or agree to terms for using google anlytics then prompted to go to your project.
Creating a firebase app for either
- android
- ios
or both by adding both setup.
Android Firebase Setup
Click on the android icon below the statement Get started by adding firebase to your project.
Register app name by adding adding the android package name.
Download the google-services.json file and id 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 line classpath '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 adding the iOS bundle ID.
Download the GoogleService-Info.plist file and id 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 init
Open your Podfile and add:
# add pods for desired Firebase products # https://firebase.google.com/docs/push-notifications/ios/setup#available-pods
Save the file and run:
$ pod install
This creates an
.xcworkspace
file 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.m
file.@import UIKit; @import Firebase; @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [FIRApp configure]; return YES; }
Add APNs Certificate to Firebase Cloud Messaging
From Project Overview from Fibase Console of your Project
- Read guide to obtain 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 Cerficate APNs you have generated
Getting App Keys and App Messenger Id
To obtain the Server Key and Sender Id. Go to:
- On the side bar next to project overview there is a setting icon with a collapsible list.
- Select Project setting
- Select Cloud Messaging tab get the Server Key and Sender ID,
- Copy the Server Key and Sender ID that you will use to configure BILDIT-CMS firebase push feature or setting up oneSignal account.