Tutorial: Guide to setup up Firebase Cloud Messaging for iOS and Android

Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably deliver messages at no cost.

Using FCM, you can notify a client app that new email or other data is available to sync. You can send notification messages to drive user reengagement and retention. For use cases such as instant messaging, a message can transfer a payload of up to 4KB to a client app.

You need an iOS device and Apple Developer account to test push notifications and wont work on Simulators.

1. Creating a Project in FCM Console

CREATE NEW PROJECT

  1. Goto Firebase Console and click on CREATE NEW PROJECT

CREATE NEW PROJECT

  1. Click on Project Settings Gear Icon and goto project settings.

Project Settings

1.2. How to add an iOS App to FCM Project

CREATE iOS App

  1. Select Add Firebase to your iOS app and enter the bundle id, nickname and click ADD APP.

Copy Config File

  1. Add the downloaded GoogleService-Info.plist into the root of your Xcode project by selecting all Targets.

Firebase pod

  1. Pod installation steps

    1. Create a pod file if you don't have one $ pod init

    2. Open you pod file and add pod 'Firebase/Core'

    3. Save the file and run $ pod install

Finish Setup

  1. Finish the setup!

P12 Upload

  1. Upload the .P12 file

FCM Server Key

  1. Copy the Firebase Cloud Messaging Token or Server Key(deprecated, but works) and give it to server team for Server Side implementation.

  1. Goto FCM iOS Setup Guide. Download Sample iOS Code

Project Settings

1.3. How to add an Android App to FCM Project

Create Android App

  1. Select Add Firebase to your Android app and enter the Package name, nickname and click ADD APP.

Copy Config File

  1. Add the downloaded GoogleService-Info.json into the module root directory of your Android App.

Firebase Gradle

  1. Gradle Steps

    1. Project-level build.gradle (project/build.gradle) classpath 'com.google.gms:google-services:3.0.0'

    2. App-level build.gradle apply plugin: 'com.google.gms.google-services'

    3. Finally, press "Sync now"in the bar that appears in the IDE

  1. Finish the setup!

FCM Server Key

  1. Copy the Firebase Cloud Messaging Token or Server Key(deprecated, but works) and give it to server team for Server Side implementation.

  1. Goto FCM Android Setup Guide. Download Sample Android Code