Client Push

Client Push is a feature that is available in Back4App’s Parse API, although 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. You will need to create credentials and certificates to use the enable Push Notifications. Check out the guide below for some insight on how to do so:

Push Notification via Dashboard

Now, to the first step.

Step 1 – Enable Client Push

First, go to your Dashboard and locate the following item:

Core Settings

Click on “Server” and locate the following button:

client_push_edit

After that, most fields will be editable. Find the checkbox named “Allow Push Notification from Client” and check it:

client_push_allow

Then, hit the Save button and you are set with the Client Push configuration. Now, it is necessary to add a few lines of code to the App.

Step 2 – Add code to the App

To use the Client Push in your app, you should add the following snippet to your code right after the Parse initialization:

ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("GCMSenderId", "Your GCM Sender ID here");
installation.saveInBackground();

Then, use the ParsePush query, as follows:

ParseQuery pushQuery = ParseInstallation.getQuery();
// Here you can personalize your pushQuery
// Add channels as you like, or remove this part to reach everyone
LinkedList<String> channels = new LinkedList<String>();
channels.add("group_1");
// Change this "message" String to change the message sent
String message = "Back4App says Hi!";
// In case you want to send data, use this
JSONObject data = new JSONObject("{\"rating\": \"5 stars\"}");

ParsePush push = new ParsePush();
// Set our Installation query
push.setQuery(pushQuery);
// Sets the channels
push.setChannels(channels);
// Sets the message
push.setMessage(message);
// Sets the data
push.setData(data);
push.sendInBackground();

More options are available in the Parse Server Documentation:

http://parseplatform.github.io/docs/android/guide/#push-notifications

And that should be enough to use the Client Push.