Skip to content

Instantly share code, notes, and snippets.

@don
Last active August 29, 2015 14:24
Show Gist options
  • Save don/49a8527a9ed310c3e09f to your computer and use it in GitHub Desktop.
Save don/49a8527a9ed310c3e09f to your computer and use it in GitHub Desktop.
iOS iBeacon
_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"];
- (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