Last active
February 22, 2017 17:51
-
-
Save casagrandebruno/18ef39373c68bad039671b4b728efa58 to your computer and use it in GitHub Desktop.
Back4App - Example of Android App for Push Notifications using GCM (Push Activity)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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