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
// 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(); | |
} |
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
final long id = 1000; | |
GeofenceProxy proxy = new GeofenceProxy(); | |
proxy.deleteGeofence(id, new Callback<Object>() { | |
@Override | |
public void onSuccess(Object result) { | |
// If you do not have push properly set up, you need to explicitly call synchronize on LocationService so it will stop generating events for this geofence | |
LocationService.getInstance().synchronize(); | |
Log.d(TAG, String.format("Successfully deleted geofence id %s", id)); | |
} |
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
// Updating a geofence with the name "Geofence 2" and adding the tag "office" | |
// In order to update a geofence, you need to pass in a valid geofence object | |
geofence.setName("Geofence 2"); | |
geofence.getTags().add("office"); | |
GeofenceProxy proxy = new GeofenceProxy(); | |
proxy.updateGeofence(geofence.getId(), geofence, new Callback<Geofence> { | |
@Override | |
public void onSuccess(Geofence result) { | |
// If you do not have push properly set up, you need to explicitly call synchronize on LocationService so it will generate events for this geofence | |
LocationService.getInstance().synchronize(); |
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
// Getting a geofence with a specific ID | |
GeofenceProxy proxy = new GeofenceProxy(); | |
proxy.getGeofence(1000, new Callback<Geofence> { | |
@Override | |
public void onSuccess(Geofence result) { | |
Log.d(TAG, geofence.toString()); | |
} | |
@Override | |
public void onFailure(Exception e) { |
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
// Creating a geofence with name "Geofence", lat/lng of ChaiOne, tag "geofence-tag", radius 250 meters | |
GeofenceProxy proxy = new GeofenceProxy(); | |
proxy.createGeofence("Geofence", 29.763638f, -95.461874f, 250, new String[]{"geofence-tag"}, | |
new Callback<Geofence> { | |
@Override | |
public void onSuccess(Geofence result) { | |
// If you do not have push properly set up, you need to explicitly call synchronize on LocationService so it will generate events for this geofence | |
LocationService.getInstance().synchronize(); | |
Toast.makeText(getActivity(), "Created geofence: " + result.getName(), Toast.LENGTH_SHORT).show(); | |
} |
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
final String id = "B89ECE55-9A3B-4998-AD58-2927F99802B7"; | |
BeaconProxy proxy = new BeaconProxy(); | |
proxy.deleteBeacon(id, new Callback<Object>() { | |
@Override | |
public void onSuccess(Object result) { | |
// If you do not have push properly set up, you need to explicitly call synchronize on ProximityService so it will stop generating events for this device | |
ProximityService.getInstance().synchronize(); | |
Log.d(TAG, String.format("Successfully deleted beacon id %s", id)); | |
} |
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
// Updating a beacon with the name "Beacon 2" and adding the tag "park" | |
// In order to update a beacon, you need to pass in a valid beacon object | |
beacon.setName("Beacon 2"); | |
beacon.getTags().add("park"); | |
BeaconProxy proxy = new BeaconProxy(); | |
proxy.updateBeacon(beacon.getId(), beacon, new Callback<Beacon> { | |
@Override | |
public void onSuccess(Beacon result) { | |
// If you do not have push properly set up, you need to explicitly call synchronize on ProximityService so it will generate events for this device | |
ProximityService.getInstance().synchronize(); |
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
// Getting a beacon with a specific ID | |
BeaconProxy proxy = new BeaconProxy(); | |
proxy.getBeacon(1000, new Callback<Beacon> { | |
@Override | |
public void onSuccess(Beacon result) { | |
Log.d(TAG, beacon.toString()); | |
} | |
@Override | |
public void onFailure(Exception e) { |