Hardware Reference
In-Depth Information
self . beaconRegion = [[ CLBeaconRegion alloc ]
initWithProximityUUID: [[ NSUUID alloc ]
initWithUUIDString:
@ "E2C56DB5-DFFB-48D2-B060-D0F5A71096E0" ]
identifier: @ "Bobs Beacon default region" ];
self . beaconRegion . notifyEntryStateOnDisplay = YES ;
[ self . locationManager startMonitoringForRegion: self . beaconRegion ];
return self ;
}
Since each iBeacon app must use a particular proximity UUID that is hardcoded into
the app through the initWithProximityUUID process earlier, it will respond only to
beacons with that UUID (the UUID that is registered with iOS when the app is down‐
loaded). This means that users have control, because they must download the app to
use it (though, once installed, the app can still receive alerts even if it is not open or
running). Without explicitly downloading the app, they will not be bombarded by un‐
wanted iBeacon alerts and notices associated with other beacons with different prox‐
imity UUIDs.
As of iOS 7.1, the operating system itself registers the beacon regions that work with
the app when the app is installed. Then, even if the app is suspended or not running,
the system will wake up the iOS app to deal with entering or exiting a beacon region,
normally within about 10 seconds.
In this next section of code, the CLBeacon class provides methods and objects to start
and stop monitoring for particular iBeacons, as well as methods that determine which
beacon is closest to the iOS device:
// start ranging beacons
- ( void ) locationManager: ( CLLocationManager *) manager
didEnterRegion: ( CLRegion *) region
{
if (![ region . identifier isEqualToString: self . beaconRegion . identifier ])
return ;
[ self . locationManager startRangingBeaconsInRegion: self . beaconRegion ];
NSLog ( @ "entered region" );
}
// stop ranging beacons
- ( void ) locationManager: ( CLLocationManager *) manager
didExitRegion: ( CLRegion *) region
{
if (![ region . identifier isEqualToString: self . beaconRegion . identifier ])
return ;
Search WWH ::




Custom Search