Skip to content

Instantly share code, notes, and snippets.

@casagrandebruno
Last active February 22, 2017 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save casagrandebruno/18ef39373c68bad039671b4b728efa58 to your computer and use it in GitHub Desktop.
Save casagrandebruno/18ef39373c68bad039671b4b728efa58 to your computer and use it in GitHub Desktop.
Back4App - Example of Android App for Push Notifications using GCM (Push Activity)
package com.example.back4app.APP_NAME;
import android.app.Application;
import android.content.Context;
import com.parse.Parse;
import com.parse.ParseInstallation;
public class PushNotification extends Application {
private static PushNotification instance = new PushNotification();
public static final String APPLICATION_ID = "YOUR_APPLICATION_ID";
public static final String CLIENT_KEY = "YOUR_CLIENT_KEY";
public static final String BACK4APP_API = "https://parseapi.back4app.com/";
public PushNotification() {
instance = this;
}
public static Context getContext() {
return instance;
}
@Override
public void onCreate() {
super.onCreate();
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId(APPLICATION_ID)
.clientKey(CLIENT_KEY)
.server(BACK4APP_API).build());
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("GCMSenderId", "YOUR_GCM_SENDER_ID");
installation.saveInBackground();
Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment