Inorder to set up a transmittor, we need to have the Beacon region and a CBPeripheralManager object.
The code is like below
-(void) initBeacon
{
NSUUID *uuid = [UUID alloc]initWithString:@"05F2F83E-C827-4F00-9FC6-452414CE1343"];
self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid major:1 minor:1 identifier:@"com.livingmobile"];
}
-(void) transmitBeacon
{
self.peripheralData = [self.beaconRegion peripheralDataWithMeasureadPower:nil];
self.peripheralManager = [[CBPeripheralManager alloc]initWithDelegate:self queue:nil options:nil];
}
We need to implement the delegate methods for getting the callback methods of the PeripheralManager. the delegate is
-(void) peripheralManagerDidUpdateState:(CBPeripheralManager* peripheral)
{
if(peripharal.state = CBPeripheralStatePoweredOn)
{
NSLog(@"Powered On");
[self.peripheralManager startAdvertising:self.peripheralData];
}
else if(peripheralState = CBPeripheralStatePoweredOff)
{
NSLog(@"Powered off");
[self.peripheralManager stopAdvertising];
}
}
The code is like below
-(void) initBeacon
{
NSUUID *uuid = [UUID alloc]initWithString:@"05F2F83E-C827-4F00-9FC6-452414CE1343"];
self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid major:1 minor:1 identifier:@"com.livingmobile"];
}
-(void) transmitBeacon
{
self.peripheralData = [self.beaconRegion peripheralDataWithMeasureadPower:nil];
self.peripheralManager = [[CBPeripheralManager alloc]initWithDelegate:self queue:nil options:nil];
}
We need to implement the delegate methods for getting the callback methods of the PeripheralManager. the delegate is
-(void) peripheralManagerDidUpdateState:(CBPeripheralManager* peripheral)
{
if(peripharal.state = CBPeripheralStatePoweredOn)
{
NSLog(@"Powered On");
[self.peripheralManager startAdvertising:self.peripheralData];
}
else if(peripheralState = CBPeripheralStatePoweredOff)
{
NSLog(@"Powered off");
[self.peripheralManager stopAdvertising];
}
}
No comments:
Post a Comment