Created
November 11, 2014 17:55
-
-
Save CHLibrarian/1a1dda15af234a929f29 to your computer and use it in GitHub Desktop.
ContextHub Application Services Sending Custom Data (Android)
This file contains hidden or 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
| // 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