Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save CHLibrarian/1a1dda15af234a929f29 to your computer and use it in GitHub Desktop.

Select an option

Save CHLibrarian/1a1dda15af234a929f29 to your computer and use it in GitHub Desktop.
ContextHub Application Services Sending Custom Data (Android)
// A class representing the custom data to send
public class MyCustomData {
String appName;
int version;
public MyCustomData(String appName, int version) {
this.appName = appName;
this.version = version;
}
}
// Send a push with custom data
String deviceId = "20984403-690A-4098-8557-73B763F1DFFB";
MyCustomData customData = new MyCustomData("NotifyMeApp", 1);
PushNotification<MyCustomData> notification = new PushNotification<MyCustomData>(customData);
notification.getDeviceIds().add(deviceId);
PushNotificationProxy proxy = new PushNotificationProxy();
proxy.sendPushNotification(notification, new Callback<Object>() {
@Override
public void onSuccess(Object result) {
Toast.makeText(getActivity(), "Push notification sent", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Exception e) {
Toast.makeText(getActivity(), e.toString(), Toast.LENGTH_SHORT).show();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment