-
Notifications
You must be signed in to change notification settings - Fork 0
/
APBeaconRegion.m
51 lines (42 loc) · 1.64 KB
/
APBeaconRegion.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// APBeaconRegion.m
// APBeacons
//
// Created by Ashutosh Priyadarshy on 10/29/13.
// Copyright (c) 2013 EEMe labs. All rights reserved.
//
#import "APBeaconRegion.h"
@interface APBeaconRegion ()
@property APBeaconService *service;
@property NSUUID *proximityUUID;
@property NSNumber *major;
@property NSNumber *minor;
@property NSString *identifier;
@end
@implementation APBeaconRegion
- (id)initWithProximityUUID:(NSUUID *)proximityUUID identifier:(NSString *)identifier
{
return [self initWithProximityUUID:proximityUUID major:[NSNumber numberWithInt:0] minor:[NSNumber numberWithInt:0] identifier:identifier];
}
- (id)initWithProximityUUID:(NSUUID *)proximityUUID major:(NSNumber *)major identifier:(NSString *)identifier
{
return [self initWithProximityUUID:proximityUUID major:major minor:[NSNumber numberWithInt:0] identifier:identifier];
}
- (id)initWithProximityUUID:(NSUUID *)proximityUUID major:(NSNumber *)major minor:(NSNumber *)minor identifier:(NSString *)identifier
{
self = [super init];
if (self) {
self.proximityUUID = proximityUUID;
self.major = major;
self.minor = minor;
self.identifier = identifier;
self.notifyEntryStateOnDisplay = NO;
}
// Move out conversion to NSData for clarity.
NSData *majorData = [[self.major stringValue] dataUsingEncoding:NSUTF8StringEncoding];
NSData *minorData = [[self.minor stringValue] dataUsingEncoding:NSUTF8StringEncoding];
// Initialize the APBeaconService (the BLE service).
self.service = [[APBeaconService alloc] initWithProximityUUID:proximityUUID major:majorData minor:minorData];
return self;
}
@end