Push Notification via Dashboard

Push notifications using Firebase Cloud Messaging is available on Back4App’s Parse Service. To use it on your app, just follow the steps that come.

Step 1 – Create a project at Firebase Console

First, it is necessary to go to Firebase Console. Then, click the button ‘Create New Project’. Add your project name and your country, as in the screen:


Wait for it to create, then click the ‘Add Firebase to your Android app’:


Add the package name and press ‘Add App’:


After pressing, a screen will tell you to put a file named ‘google-services.json’ into the root of your app and will start the download of this very same file:


Hit ‘Continue’ and follow the instructions on the last step, which consist of adding this line:

classpath 'com.google.gms:google-services:3.0.0'

To the ‘build.gradle’ file that is in the project folder, not the app folder. And adding this line:

apply plugin: 'com.google.gms.google-services'

To the ‘build.gradle’ file that is in the app folder this time. Now, it is necessary to setup some configurations at Back4App.

Step 2 – Add FCM credentials to Back4App Dashboard

First, it is necessary to get FCM credentials. Go to your Firebase Console and locate this cog:


Then click on Project Settings, which will get you to a screen that has some tabs, one of which is the ‘Cloud Messaging’ tab, as below:


Click on this tab and locate your Server Key and your Sender ID, as below:


Write down both of these keys. Now, go to your Dashboard and find this option:Android Push notification


Click at “Server” and you’ll be taken to a page that has an ‘Edit’ button. Click on it and you’ll be taken to the following screen:


Then, write on the field ‘GCM Sender ID’ your Firebase Sender ID and on the ‘API Key’, your Firebase Server Key. Hit ‘Next’ and you’re set with the Backend! Now you need to set up the libraries on the App.

Step 3 – Setup libraries and add permissions

Now, we have to add to the ‘build.gradle’ file that is in the app folder the following lines in the dependencies section:

dependencies {
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.parse:parse-android:1.+'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'

This setups the libraries. After that, go to your ‘AndroidManifest.xml’ file and add the following lines right after the ‘manifest’ tag:

<manifest xmlns:android= ...
    ... >
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

So that your App has permissions required to use Push Notifications full capabilities. Right below these lines, add the following lines, but remember to complete the space with your package name:

<permission android:name="<Your package name here>.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="<Your package name here>.permission.C2D_MESSAGE" />

Now, we have to add the Sender Key to the ‘AndroidManifest.xml’ file. Right below the ‘</activity>’ section, add:

<activity ...
<meta-data android:name="com.parse.push.gcm_sender_id"
    android:value="id:<Your Firebase Sender Key here>" />

And change the fields to have your Firebase Sender Key in the right place. After this, we have to grant Parse API permission to receive push notifications. Immediately below the Sender Key you just added, add this piece of code:

<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
    <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
    <category android:name="<Your Package name here>" />
<receiver android:name="com.parse.ParsePushBroadcastReceiver" android:exported="false">
    <action android:name="com.parse.push.intent.RECEIVE" />
    <action android:name="com.parse.push.intent.OPEN" />
    <action android:name="com.parse.push.intent.DELETE" />

Note that you have to modify fields accordingly, in this case by adding your package name where it is asked to. Now, we have to create an installation, so that Parse API can receive the notifications.

Step 4 – Create Installation

Right after your Parse initialization, add the setup of the ‘Installation’:

// Back4App's Parse setup
Parse.initialize(new Parse.Configuration.Builder(this)
        .applicationId("<Your App ID here>")
        .clientKey("<Your client Key here>")

// This is the installation part
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("GCMSenderId", "<Your Firebase Sender Key here>");

Just remember to fill the fields with your own informations, such as your App ID and Client Key, as well as your Firebase Sender Key. Now you are set to use the Push Notifications! To test it, just go to your Parse Dashboard and find ‘Push’. Locate ‘Send New Push’:


Click on it and there will be a screen to test your push notifications on your right. Select the ‘Audience’ you wish, type a message and click ‘Send push’:


Here is a screenshot of the app working:


And that’s it for Push Notifications with Dashboard!