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
NSString *updatedAlias = @"[email protected]"; | |
NSString *updatedTag1 = @"Austin"; | |
NSString *updatedTag2 = @"Field Rep"; | |
// Update device with new alias and tags | |
[[CCHDevice sharedInstance] setAlias:updatedAlias tags:@[updatedTag1, updatedTag2] completionHandler:^(NSDictionary *device, NSError *error)completionHandler { | |
if (!error) { | |
NSLog(@"Device alias/tag updated"); | |
} else { | |
NSLog(@"Failed to set new alias/tag for device in ContextHub"); | |
} |
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
NSString *deviceTag1 = @"Houston"; | |
NSString *deviceTag2 = @"Engineer"; | |
// Retrieve all devices that have the tag "Houston" and "Engineer" | |
[[CCHDevice sharedInstance] getDevicesWithTags:@[deviceTag1, deviceTag2] completionHandler:^(NSArray *devices, NSError *error)completionHandler { | |
if (!error) { | |
// Access individual devices here | |
NSArray *retrievedDevices = devices; | |
} else { | |
NSLog(@"Error retrieving devices by tags from ContextHub"); | |
} |
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
NSString *deviceAlias = @"[email protected]"; | |
// Retrieve devices with alias "[email protected]" | |
[[CCHDevice sharedInstance] getDevicesWithAlias:deviceAlias completionHandler:^(NSArray *devices, NSError *error)completionHandler { | |
if (!error) { | |
// Access individual devices here | |
NSArray *retrievedDevices = devices; | |
} else { | |
NSLog(@"Error retrieving devices by alias from ContextHub"); | |
} | |
}]; |
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
NSString *deviceToRetrieveID = @"76BC4719-6344-4E62-8FA2-F00A8D29B60E"; | |
// Retrieve device from ContextHub | |
[[CCHDevice sharedInstance] getDeviceWithId:deviceToRetrieveID completionHandler:^(NSDictionary *device, NSError *error)completionHandler { | |
if (!error) { | |
NSString *deviceID = device[@"id"]; | |
NSString *deviceType = device[@"device_type"]; | |
// Not present if not previously set | |
NSString *deviceAlias = device[@"alias"]; | |
NSArray *deviceTags = device[@"tags"]; |
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
// Retrieve device ID (in standard 8-4-4-4-12 UUID format, ex: 76BC4719-6344-4E62-8FA2-F00A8D29B60E) | |
NSString *deviceID = [CCHDevice deviceID]; |
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
NSString *logMessage = @"Logging message"; | |
NSDictionary *logDictionary = @{@"key1": @"value1", @"key2": @"value2"}; | |
// Logging a message and a custom valid-JSON dictionary to ContextHub | |
[[CCHLog sharedInstance] log:logMessage userInfo:logDictionary completionHandler:(void (^)(NSError *error))completionHandler { | |
if (!error) { | |
NSLog(@"Message logged successfully"); | |
} else { | |
NSLog(@"Failed to log message to Contexthub"); | |
} | |
}]; |
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
public class MyContextHubApp extends Application { | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
// Register with ContextHub | |
ContextHub.init(this, "YOUR-APP-ID-HERE"); | |
} | |
} |
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
@Override | |
public void onResume() { | |
super.onResume(); | |
// start listening to events | |
ContextHub.getInstance().addSensorPipelineListener(this); | |
} | |
@Override | |
public void onPause() { |
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
// Unsubscribing from tag "my-tag-2" | |
// We want to unsubscribe from tag "my-tag-2", so we specify the REMOVE operation and the tag to remove. | |
SubscriptionProxy proxy = new SubscriptionProxy(); | |
List<String> tagList = Arrays.asList("my-tag-2"); | |
List<String> subscriptionTypes = Arrays.asList("beacon", "geofence", "vault"); | |
proxy.updateSubscriptions(SubscriptionOperation.REMOVE, tagList, subscriptionTypes, new Callback<SubscriptionResponse>() { | |
@Override | |
public void onSuccess(SubscriptionResponse result) { | |
Toast.makeText(getActivity(), ("Beacon, geofence, and vault subscriptions removed", 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
// Getting tag subscriptions | |
SubscriptionProxy proxy = new SubscriptionProxy(); | |
proxy.listSubscriptions(new Callback<SubscriptionResponse>() { | |
@Override | |
public void onSuccess(SubscriptionResponse result) { | |
Log.d(TAG, result.getBeaconSubscription().toString()); | |
Log.d(TAG, result.getGeofenceSubscription().toString()); | |
Log.d(TAG, result.getVaultSubscription().toString()); | |
} | |
NewerOlder