Skip to content

Commit

Permalink
Check new beacons against currently monitored beacons
Browse files Browse the repository at this point in the history
  • Loading branch information
lmeier committed Sep 19, 2023
1 parent 34b4ed3 commit d7dbfff
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion RadarSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RadarSDK'
s.version = '3.8.8'
s.version = '3.8.9-beta.2'
s.summary = 'iOS SDK for Radar, the leading geofencing and location tracking platform'
s.homepage = 'https://radar.com'
s.author = { 'Radar Labs, Inc.' => '[email protected]' }
Expand Down
8 changes: 4 additions & 4 deletions RadarSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand All @@ -973,7 +973,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MARKETING_VERSION = 3.8.8;
MARKETING_VERSION = 3.8.9;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -1018,7 +1018,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -1031,7 +1031,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MARKETING_VERSION = 3.8.8;
MARKETING_VERSION = 3.8.9;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
OTHER_CFLAGS = "-fembed-bitcode";
Expand Down
24 changes: 21 additions & 3 deletions RadarSDK/RadarBeaconManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,21 @@ - (void)rangeBeacons:(NSArray<RadarBeacon *> *_Nonnull)beacons completionHandler

return;
}

self.beacons = beacons;

self.started = YES;

// Use a set for faster lookup
NSMutableSet *currentBeaconIDs = [NSMutableSet set];
for (RadarBeacon *currentBeacon in self.beacons) {
[currentBeaconIDs addObject:currentBeacon._id];
}


for (RadarBeacon *beacon in beacons) {
if ([currentBeaconIDs containsObject:beacon._id]) {
// Already ranging this beacon, skip
continue;
}
CLBeaconRegion *region = [self regionForBeacon:beacon];

if (region) {
Expand All @@ -165,6 +175,7 @@ - (void)rangeBeacons:(NSArray<RadarBeacon *> *_Nonnull)beacons completionHandler
beacon.uuid, beacon.major, beacon.minor]];
}
}
self.beacons = [self.beacons arrayByAddingObjectsFromArray:beacons];
}

- (void)rangeBeaconUUIDs:(NSArray<NSString *> *_Nonnull)beaconUUIDs completionHandler:(RadarBeaconCompletionHandler)completionHandler {
Expand Down Expand Up @@ -207,10 +218,15 @@ - (void)rangeBeaconUUIDs:(NSArray<NSString *> *_Nonnull)beaconUUIDs completionHa
return;
}

self.beaconUUIDs = beaconUUIDs;
self.started = YES;
NSMutableSet *currentBeaconUUIDsSet = [NSMutableSet setWithArray:self.beaconUUIDs];


for (NSString *beaconUUID in beaconUUIDs) {
if ([currentBeaconUUIDsSet containsObject:beaconUUID]) {
// Already ranging this UUID, skip
continue;
}
CLBeaconRegion *region = [self regionForUUID:beaconUUID];

if (region) {
Expand All @@ -221,6 +237,8 @@ - (void)rangeBeaconUUIDs:(NSArray<NSString *> *_Nonnull)beaconUUIDs completionHa
[[RadarLogger sharedInstance] logWithLevel:RadarLogLevelDebug message:[NSString stringWithFormat:@"Error starting ranging UUID | beaconUUID = %@", beaconUUID]];
}
}

self.beaconUUIDs = [self.beaconUUIDs arrayByAddingObjectsFromArray:beaconUUIDs];
}

- (void)stopRanging {
Expand Down
7 changes: 5 additions & 2 deletions RadarSDK/RadarLocationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ @interface RadarLocationManager ()
@property (assign, nonatomic) int startedInterval;

/**
`YES` if `RadarAPIClient.trackWithLocation() has been called, but the
`YES` if `RadarAPIClient.trackWithLocation() hasp been called, but the
response hasn't been received yet.
*/
@property (assign, nonatomic) BOOL sending;
Expand Down Expand Up @@ -982,7 +982,10 @@ - (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegion
[self handleLocation:location source:RadarLocationSourceBeaconEnter beacons:nearbyBeacons];
}];
}
} else {
} else if (state == CLRegionStateUnknown) {
[[RadarLogger sharedInstance] logWithLevel:RadarLogLevelDebug message:[NSString stringWithFormat:@"Unknown beacon region | identifier = %@", region.identifier]];
}
else {
[[RadarLogger sharedInstance] logWithLevel:RadarLogLevelDebug message:[NSString stringWithFormat:@"Outside beacon region | identifier = %@", region.identifier]];

if ([region.identifier hasPrefix:kSyncBeaconUUIDIdentifierPrefix]) {
Expand Down
2 changes: 1 addition & 1 deletion RadarSDK/RadarUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ + (NSNumber *)timeZoneOffset {
}

+ (NSString *)sdkVersion {
return @"3.8.8";
return @"3.8.9-beta.2";
}

+ (NSString *)deviceId {
Expand Down

0 comments on commit d7dbfff

Please sign in to comment.