-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeaconHelper.m
More file actions
60 lines (40 loc) · 1.16 KB
/
BeaconHelper.m
File metadata and controls
60 lines (40 loc) · 1.16 KB
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
52
53
54
55
56
57
58
59
60
//
// BeaconHelper.m
// BeaconCoreData
//
// Created by Achyut Kumar Maddela on 24/08/15.
// Copyright (c) 2015 iAKM. All rights reserved.
//
#import "BeaconHelper.h"
@implementation BeaconHelper
+(NSString *)proximityStringForBeacon:(CLBeacon *)beacon;
{
NSString *proximity;
switch (beacon.proximity)
{
case CLProximityFar:
proximity = @"Far";
break;
case CLProximityNear:
proximity = @"Near";
break;
case CLProximityImmediate:
proximity = @"Immediate";
break;
case CLProximityUnknown:
proximity = @"Unknown";
break;
}
return proximity;
}
+(NSString *)stringForBeacon:(CLBeacon *)beacon
{
NSString *proximity = [self proximityStringForBeacon:beacon];
return [NSString stringWithFormat:@"%@:%@:%@", beacon.major, beacon.minor, proximity];
}
+(NSArray *)beaconsNearbyForBeacons:(NSArray *)beacons;
{
NSArray *nearbyBeacons = [beacons filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"proximity >= %d", CLProximityNear]];
return [NSArray arrayWithArray:nearbyBeacons];
}
@end