Last active
August 29, 2015 14:24
-
-
Save don/49a8527a9ed310c3e09f to your computer and use it in GitHub Desktop.
iOS iBeacon
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
_peripheralManager = [[CBPeripheralManager alloc] | |
initWithDelegate:self | |
queue:nil]; | |
NSUUID *uuid = [[NSUUID alloc] | |
initWithUUIDString:@"12345678-AAAA-BBBB-CCCC-123456789ABC"]; | |
_region = [[CLBeaconRegion alloc] | |
initWithProximityUUID:uuid | |
major:1 | |
minor:1 | |
identifier:@"com.example.beacon"]; |
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
- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral | |
{ | |
// Ignore anything but powered on | |
if (peripheral.state != CBPeripheralManagerStatePoweredOn) { | |
return; | |
} | |
NSDictionary *peripheralData = [_region peripheralDataWithMeasuredPower:nil]; | |
[_peripheralManager startAdvertising:peripheralData]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment