Skip to content

Commit

Permalink
RadarSettings --> RadarState
Browse files Browse the repository at this point in the history
  • Loading branch information
lmeier committed Dec 19, 2024
1 parent aa42fb1 commit 4ced992
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion RadarSDK/RadarAPIClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ - (void)makeTrackRequestWithParams:(NSDictionary *)params
NSMutableDictionary *bufferParams = [params mutableCopy];
bufferParams[@"replayed"] = @(YES);

[RadarSettings setRegisteredNotifications:notificationsRemaining];
[RadarState setRegisteredNotifications:notificationsRemaining];

[[RadarReplayBuffer sharedInstance] writeNewReplayToBuffer:bufferParams];
} else if (options.replay == RadarTrackingOptionsReplayStops && stopped &&
Expand Down
4 changes: 2 additions & 2 deletions RadarSDK/RadarNotificationHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ + (void)addOnPremiseNotificationRequests:(NSArray<UNNotificationRequest *> *)req
}
}];
}
[RadarSettings setRegisteredNotifications:registeredNotifications];
[RadarState setRegisteredNotifications:registeredNotifications];
} else {
[[RadarLogger sharedInstance] logWithLevel:RadarLogLevelDebug message:@"Notification permissions not granted. Skipping adding notifications."];
return;
Expand All @@ -204,7 +204,7 @@ + (void)addOnPremiseNotificationRequests:(NSArray<UNNotificationRequest *> *)req

+ (void)getNotificationDiffWithCompletionHandler:(void (^)(NSArray *notificationsDelivered, NSArray *notificationsRemaining))completionHandler {
UNUserNotificationCenter *notificationCenter = [UNUserNotificationCenter currentNotificationCenter];
NSArray *registeredNotifications = [RadarSettings registeredNotifications];
NSArray *registeredNotifications = [RadarState registeredNotifications];

[notificationCenter getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> *requests) {
NSMutableArray *currentNotifications = [NSMutableArray new];
Expand Down
2 changes: 0 additions & 2 deletions RadarSDK/RadarSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)setLogLevel:(RadarLogLevel)level;
+ (NSArray<NSString *> *_Nullable)beaconUUIDs;
+ (void)setBeaconUUIDs:(NSArray<NSString *> *_Nullable)beaconUUIDs;
+ (NSArray<NSDictionary *> *_Nullable)registeredNotifications;
+ (void)setRegisteredNotifications:(NSArray<NSDictionary *> *_Nullable)registeredNotifications;
+ (NSString *)host;
+ (void)updateLastTrackedTime;
+ (NSDate *)lastTrackedTime;
Expand Down
9 changes: 0 additions & 9 deletions RadarSDK/RadarSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,6 @@ + (void)setBeaconUUIDs:(NSArray<NSString *> *_Nullable)beaconUUIDs {
[[NSUserDefaults standardUserDefaults] setValue:beaconUUIDs forKey:kBeaconUUIDs];
}

+ (NSArray<NSDictionary *> *_Nullable)registeredNotifications {
NSArray<NSDictionary *> *registeredNotifications = [[NSUserDefaults standardUserDefaults] valueForKey:kRegisteredNotifications];
return registeredNotifications;
}

+ (void)setRegisteredNotifications:(NSArray<NSDictionary *> *_Nullable)registeredNotifications {
[[NSUserDefaults standardUserDefaults] setValue:registeredNotifications forKey:kRegisteredNotifications];
}

+ (NSString *)host {
NSString *host = [[NSUserDefaults standardUserDefaults] stringForKey:kHost];
return host ? host : kDefaultHost;
Expand Down
2 changes: 2 additions & 0 deletions RadarSDK/RadarState.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)setLastMotionActivityData:(NSDictionary *_Nullable)lastMotionActivityData;
+ (void)setNotificationPermissionGranted:(BOOL)granted;
+ (BOOL)notificationPermissionGranted;
+ (NSArray<NSDictionary *> *_Nullable)registeredNotifications;
+ (void)setRegisteredNotifications:(NSArray<NSDictionary *> *_Nullable)registeredNotifications;

@end

Expand Down
8 changes: 8 additions & 0 deletions RadarSDK/RadarState.m
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,12 @@ + (BOOL)notificationPermissionGranted {
return [[NSUserDefaults standardUserDefaults] boolForKey:kNotificationPermissionGranted];
}

+ (NSArray<NSDictionary *> *_Nullable)registeredNotifications {
NSArray<NSDictionary *> *registeredNotifications = [[NSUserDefaults standardUserDefaults] valueForKey:kRegisteredNotifications];
return registeredNotifications;
}

+ (void)setRegisteredNotifications:(NSArray<NSDictionary *> *_Nullable)registeredNotifications {
[[NSUserDefaults standardUserDefaults] setValue:registeredNotifications forKey:kRegisteredNotifications];
}
@end

0 comments on commit 4ced992

Please sign in to comment.