Android
Push Notifications
via Dashboard
23min
parse server push notifications setup introduction this section explains how you can send push notifications using firebase cloud messaging and parse dashboard through back4app this is how it will look like at any time, you can access the complete android project built with this tutorial at our github repositories kotlin example repository java example repository prerequisites to complete this tutorial, we need android studio an app created on back4app note follow the new parse app tutorial to learn how to create a parse app on back4app an android app connected to back4app note follow the install parse sdk tutoria l to create an android studio project connected to back4app a device (or virtual device ) running android 4 0 (ice cream sandwich) or newer 1 link your firebase project with your android studio project to send push notifications through your dashboard, you will have to create a project at firebase website and link it to your android studio project to do so, follow the steps described below pay attention to the steps below because you are not going to follow exactly the same steps that firebase suggests go to firebase website and log in with a google account at firebase website, in the right corner click on go to console go to console and click on add project add project , then give your project a name follow the steps to create a new project 3\ then, connect your android studio project to the firebase project you created to do so, click on the android icon, as shown in the following image 4\ you will be asked to inform the package name of your android studio project, as shown in the following image 5\ to discover the package name of your android studio project, leave the firebase page opened and go to your project in android studio and go to app app > manifest manifest > androidmanifest xml androidmanifest xml in your manifest file you will be able to find the package name of your project, as you can see in the image below 6\ copy the package name in the required box at the firebase page you can also fill the other fields, but they are optional after that, click on the register app register app button 7\ now, you have to download google services json google services json file and move it to your android studio project module root directory 1 classpath 'com google gms\ google services\ latest version here' 9\ after that, go to the build gradle (module\ app) build gradle (module\ app) file and, on the top of the file, add the code below 1 apply plugin 'com google gms google services' 10\ continue on the build gradle (module\ app)` file and add these lines of code 1 // don't forget to change the line below with the latest versions of firebase sdks 2 implementation 'com google firebase\ firebase core\ latest version here' 3 implementation 'com google firebase\ firebase messaging\ latest version here' don’t forget to change these lines with the latest versions of firebase sdks 2 link your firebase project with back4app to link your firebase project with back4app and easily send push notification through your dashboard, simply follow these steps go to back4app website , log in, find your app and click on server settings server settings find the “android push notification” block and click on settings settings > edit edit the “android push notification” block looks like this 3\ leave the back4app android push notification page you visited opened and go to your project on the firebase website 4\ click on the settings icon and then the project settings project settings button, as shown below 5\ click on cloud messaging cloud messaging and then on manage service accounts 6\ click on manage details (under actions) 7\ go to keys > add key > create new key 8\ choose the json format and create 9\ to set up your service account configuration, click on the set up push settings button 10\ to finish the configuration, click on the choose file button and select the json file you got from firebase and next 3 set up the manifest file open your project at android studio and go to app app > manifest manifest > androidmanifest xml androidmanifest xml in this file, use the code below right after the meta data meta data tags that are inside the application application tag 1 \<meta data android\ name="com parse push gcm sender id" 2 android\ value="insert your sender id" /> don’t forget to insert the gcm sender id gcm sender id you obtained at firebase in this line of code 2\ use the following code right before the application application tag ends androidx 1 \<service android\ name="com parse fcm parsefirebasemessagingservice" android\ exported="false"> 2 \<intent filter> 3 \<action android\ name="com google firebase messaging event"/> 4 \</intent filter> 5 \</service> 6 7 \<receiver android\ name="com parse parsepushbroadcastreceiver" android\ exported="false"> 8 \<intent filter> 9 \<action android\ name="com parse push intent receive" /> 10 \<action android\ name="com parse push intent open" /> 11 \<action android\ name="com parse push intent delete" /> 12 \</intent filter> 13 \</receiver> android 1 \<service android\ name="com parse fcm parsefirebaseinstanceidservice" android\ exported="false"> 2 \<intent filter> 3 \<action android\ name="com google firebase instance id event" /> 4 \</intent filter> 5 \</service> 6 7 \<service 8 android\ name="com parse fcm parsefirebasemessagingservice" android\ exported="false"> 9 \<intent filter> 10 \<action android\ name="com google firebase messaging event"/> 11 \</intent filter> 12 \</service> 13 14 \<receiver android\ name="com parse parsepushbroadcastreceiver" android\ exported="false"> 15 \<intent filter> 16 \<action android\ name="com parse push intent receive" /> 17 \<action android\ name="com parse push intent open" /> 18 \<action android\ name="com parse push intent delete" /> 19 \</intent filter> 20 \</receiver> use the following permissions right after the uses permission uses permission tags that you placed to allow your app to have access to internet 1 \<uses permission android\ name="android permission wake lock" /> 2 \<uses permission android\ name="android permission vibrate" /> 3 \<uses permission android\ name="android permission receive boot completed" /> 4 \<uses permission android\ name="android permission get accounts" /> 5 \<uses permission android\ name="com google android c2dm permission receive" /> you added permissions to allow internet access in the install parse sdk tutorial instructions if you didn’t, access install parse sdk tutorial and follow its steps 4 set up build gradle (module app) install the parse fcm sdk and the parse bolts sdk for android to do so, open build gradle (module app) build gradle (module app) and add the code below in the dependecies{} dependecies{} tag 1 // don't forget to change the lines belows with the latest versions these sdks 2 implementation "com github parse community parse sdk android\ fcm\ latest version here" 3 implementation 'com parse bolts\ bolts android\ latest version here' don’t forget to change these lines with the latest versions of these sdks if you are not using androidx, you cannot use the latest version check the changelog 5 create an installation every parse application installed on a device registered for push notifications has an associated installation object that stores all the data needed to target push notifications in android, installation objects are available through the parseinstallation parseinstallation class this class uses the same api for storing and retrieving data to access the current installation object from your android app, use the parseinstallation getcurrentinstallation() parseinstallation getcurrentinstallation() method in the first time you save a parseinstallation, parse will add it to your installation class and it will be available for targeting push notifications to create a parseinstallation parseinstallation in your app, go to your android studio project and in the java file called app app that extends application that you created to initialize the parse sdk, on its oncreate oncreate method, right after parse initialize() parse initialize() call, use the following code to create a parseinstallation parseinstallation 1 parseinstallation installation = parseinstallation getcurrentinstallation (); 2 installation put ( "gcmsenderid" , insert your sender id ); 3 installation saveinbackground (); don’t forget to insert the gcm sender id gcm sender id you obtained at firebase in the code above if you don’t have an app java app java file as described in this step, access the install parse sdk for android https //www back4app com/docs/android/parse android sdk documentation and make sure that you have followed all the steps required to install parse sdk correctly if you do not install parse sdk properly your facebook login with parse will not work 6 test your app go to back4app website , log in, find your app and click on dashboard dashboard click on > push push > send new push send new push and create an audience for your push notification 3\ write your message and look at the preview by clicking at the android option 4\ if you already reviewed the push notification and you want to send it, click on send push send push you may explore the other options for push notification at parse dashboard parse dashboard there, it’s also possible to look at past pushes past pushes you sent and the audiences audiences you created for them it’s done! at this stage, you can send push notifications using the parse dashboard through back4app!