Reputation: 447
Beacon region monitoring was introduced in iOS7. And I have a App with 4.3 as deployment target. I need to update the App with the new requirement for beacon region monitoring.
what are the other ways that I can achieve this.
Thanks,
Upvotes: 0
Views: 263
Reputation: 17585
If you want to implement region monitoring using beacon tech, You should do build application on xcode 5.0+, and deployment target should be ios7+. But you can do with xcode 4.6 but you have to know about add base sdk as IOS7+.
See this reference document which support for beacon,
CLBeaconRegion available from IOS7, CLBeacon available from IOS7.
Note: In IOS, your iphone can also act as beacon device(normally beacon is an external bluetooth device,see this ref) broadcast(advertising beacon) via Bluetooth LE hardware which is only available in iPhone 4S, iPhone 5,5c,5s. iPad 4,iPad Mini, iPad Air..etc. So When you support for beacon, you have to note about hardware also.
Upvotes: 3
Reputation: 64916
You CAN build iBeacon applications using XCode 4.x targeting older iOS releases. The setup is a bit tricky and these apps can only use the iBeacon functionality on phones with iOS7 or later. But it can still run on earlier iOS versions.
The trick is that you first have to make a binary wrapper around the iBeacon APIs using XCode 5. This wrapper code must query the CoreLocation
classes to see if the iBeacon APIs exist, and exit gracefully if they do not. You only have to use XCode 5 to compile this binary, then you add it into your XCode 4.x project (along with your header file so source code can access the class interface).
Below is a snippet of the code from a class that accomplishes this for monitoring iBeacons. You would have to add additional methods for ranging.
typedef void(^RNDetermineStateCompletionHandler)(NSInteger state, CLRegion *region);
- (id)init {
self = [super init];
if (self != nil) {
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
}
return self;
}
- (BOOL)isIBeaconCapable {
return [CLLocationManager isRangingAvailable];
}
- (void)setUUID:(NSString *)uuidStr {
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidStr];
NSLog(@"RNLocation Wrapper: Set UUID to %@", uuidStr);
_beaconRegion = [[NSClassFromString(@"CLBeaconRegion") alloc] initWithProximityUUID:uuid identifier:@"my.region.identifier"];
}
- (void)monitorBeaconRangeWithHandler:(RNDetermineStateCompletionHandler)completionHandler {
for (CLBeaconRegion *region in [_locationManager monitoredRegions]) {
NSLog(@"Stopping monitoring on: %@ ", region.identifier);
[_locationManager stopMonitoringForRegion:region];
}
_stateBlock = completionHandler;
[_locationManager startMonitoringForRegion:_beaconRegion];
}
- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region {
if (_stateBlock) {
_stateBlock(state, region);
}
}
Upvotes: 0
Reputation: 23271
The Core Location framework provides two ways to detect a user’s entry and exit into specific regions: geographical region monitoring (iOS 4.0 and later and OS X 10.8 and later) and beacon region monitoring (iOS 7.0 and later). A geographical region is an area defined by a circle of a specified radius around a known point on the Earth’s surface. In contrast, a beacon region is an area defined by the device’s proximity to Bluetooth low energy beacons. Beacons themselves are simply devices that advertise a particular Bluetooth low energy payload—you can even turn your iOS device into a beacon with some assistance from the Core Bluetooth framework.
Upvotes: 0