Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CHLibrarian/1876275ccb198d441293 to your computer and use it in GitHub Desktop.
Save CHLibrarian/1876275ccb198d441293 to your computer and use it in GitHub Desktop.
ContextHub Element Services Subscription Add (Android)
// Subscribing to a tag
// We want to subscribe to tags "my-tag- 1" and "my-tag-2" to be notified when beacons, geofences, or vault records with that tag are created, updated, or deleted
SubscriptionProxy proxy = new SubscriptionProxy();
List<String> tagList = Arrays.asList("my-tag-1", "my-tag-2");
List<String> subscriptionTypes = Arrays.asList("beacon", "geofence", "vault");
proxy.updateSubscriptions(SubscriptionOperation.ADD, tagList, subscriptionTypes, new Callback<SubscriptionResponse>() {
@Override
public void onSuccess(SubscriptionResponse result) {
Toast.makeText(getActivity(), ("Beacon, geofence, and vault subscriptions added", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Exception e) {
Toast.makeText(getActivity(), ("Error adding beacon, geofence, and vault subscriptions", Toast.LENGTH_SHORT).show();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment