Last active
August 29, 2015 14:05
-
-
Save CHLibrarian/d9bc6b5675b062b11dbf to your computer and use it in GitHub Desktop.
ContextHub Element Services Beacon Update Gist
This file contains 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 dictionary with the same dictionary structure as from either the create or get methods | |
// Note, this is where a custom class is very helpful in taking the information in a CLBeaconRegion (which is marked partly read-only by Apple) and updating it | |
// See DMBeacon in DetectMe sample app for more information | |
NSString *name = @"Beacon 2"; | |
NSString *uuidString = @"B9407F30-F5F8-466E-AFF9-25556B57FE6D"; | |
CLBeaconMajorValue major = 100; | |
CLBeaconMinorValue minor = 1; | |
NSString *beaconTag = @"beacon-tag"; | |
NSString *beaconTag2 = @"park"; | |
NSNumber *beaconID = @1000; | |
NSDictionary *beaconDict = @{ @"id":beaconID, @"major": major, @"minor":minor, @"uuid": uuidString, @"tags":@[beaconTag, beaconTag2] }; | |
[[CCHBeaconService sharedInstance] updateBeacon:beaconDict completionHandler:^(NSError *error) { | |
if (!error) { | |
NSLog(@"Updated beacon in ContextHub"); | |
// If you do not have push properly set up, you need to explicitly call synchronize on CCHSensorPipeline so it will start/stop generate events if it applies to this device | |
[[CCHSensorPipeline sharedInstance] synchronize:^(NSError *error) { | |
if (!error) { | |
NSLog(@"Successfully synchronized with ContextHub"); | |
} else { | |
NSLog(@"Could not synchronize with ContextHub"); | |
} | |
}]; | |
} else { | |
NSLog(@"Could not update beacon in ContextHub"); | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment