Android
Push Notifications

from client side

9min

Send Parse push notifications from client side

Introduction

Client Push is a feature that is available on Back4App’s Parse API, however it is not enabled by default due to security issues.

Enabling Client Push and allowing your App to use its features is quite simple, but not encouraged. The main function of Client Push is for debugging and test purposes.

In this tutorial an example app will be built and this is how it will look like:

Document image


At any time, you can access the complete Android Project built with this tutorial at our Github repository.

Prerequisites

To complete this tutorial, we need:

1 - Enable Client Push

  1. Go to Back4App Website, log in, find your app and click on Server Settings.
  2. Find the “Core Settings” block and click on SETTINGS. The “Core Settings” block looks like this:
Document image


3. Scroll to the end of the page and click on the EDIT DETAILS button, as shown below:

Document image


4. You will see a checkbox called Allow Push Notification from Client in the end of the edit page, tick that box and click on the SAVE button, as shown below:

Document image


2 - Push from your app

  1. At the beginning of your activity, import the following dependencies:
// Imports to the JSONObject object, necessary for the push message import org.json.JSONException; import org.json.JSONObject; // Parse Dependencies import com.parse.ParsePush;

2. Use ParsePush to send the push message, as shown in the following code:

Remember to set up the channels and the message.

JSON


3. To test the push notifications, just call that function while the device is opened.

It’s done!

At this stage, you can send push notifications using your own device with Client Push through Back4App!

To learn more about Android push notification, see Parse Android Push Notification Official Documentation.



Updated 29 Mar 2024
Did this page help you?