Skygear Push Basics
To setup your android app with the FCM SDK, please use the Skygear Android SDK v1.7.0 or later.
For migrating to FCM from the older version Skygear Android SDK, please read Migrate to FCM from GCM
Once you have setup FCM in Skygear properly, you will need to enable receiving push notifications in the client app on Android. You need to:
- Add Firebase to the project
- Setup
FirebaseMessagingServiceto register token and receive message
Add Firebase to the project
-
In the General tab of the project settings, select the Android icon to register your app.

Complete the steps to add your app into the Firebase project. Download the
google-services.jsonfile during the registration process. You can get back this file anytime in the General tab. Put thegoogle-services.jsoninto your Android app module root directory. -
Add the Google services plugin into your project by modifying the
build.gradlefiles. The plugin will load thegoogle-services.jsonfile.Project-level
build.gradle(<project>/build.gradle):buildscript { dependencies { // Add this line classpath 'com.google.gms:google-services:4.0.1' } }App-level
build.gradle(<project>/<app-module>/build.gradle):dependencies { // Add this line implementation 'com.google.firebase:firebase-core:16.0.6' } ... // Add to the bottom of the file apply plugin: 'com.google.gms.google-services'
Setup FirebaseMessagingService to register token and receive message
There are two ways to setup FirebaseMessagingService:
- Use Skygear default
FirebaseMessagingService, it will help you to handle the token registration and simply display the message in android default Notification. - Create your own
FirebaseMessagingService, use the Skygear SDK to send the token to Skygear and customize the codes inonMessageReceived.
Option 1: Use Skygear default FirebaseMessagingService
-
Update the
AndroidManifest.xmlfile in your application, include the following in the manifest:<service android:name="io.skygear.skygear.fcm.FirebaseMessagingService"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service>
Option 2: Create your own FirebaseMessagingService
-
Create your own
FirebaseMessagingServiceclass, extendscom.google.firebase.messaging.FirebaseMessagingService. Override methodonNewTokenandonMessageReceived. -
Update the
AndroidManifest.xmlfile in your application. Include the following in the manifest:<service android:name=".YourFirebaseMessagingService"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service>