Skip to content

Commit

Permalink
Added CLYConsentRemoteConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
erkanyildiz committed Nov 1, 2020
1 parent d001f4b commit 16f384b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions CountlyConfig.h
Expand Up @@ -74,6 +74,7 @@ extern CLYConsent const CLYConsentStarRating DEPRECATED_MSG_ATTRIBUTE("Please us
extern CLYConsent const CLYConsentAppleWatch;
extern CLYConsent const CLYConsentPerformanceMonitoring;
extern CLYConsent const CLYConsentFeedback;
extern CLYConsent const CLYConsentRemoteConfig;

//NOTE: Push Notification Test Modes
typedef NSString* CLYPushTestMode NS_EXTENSIBLE_STRING_ENUM;
Expand Down
1 change: 1 addition & 0 deletions CountlyConsentManager.h
Expand Up @@ -21,6 +21,7 @@
@property (nonatomic, readonly) BOOL consentForAppleWatch;
@property (nonatomic, readonly) BOOL consentForPerformanceMonitoring;
@property (nonatomic, readonly) BOOL consentForFeedback;
@property (nonatomic, readonly) BOOL consentForRemoteConfig;

+ (instancetype)sharedInstance;
- (void)giveConsentForFeatures:(NSArray *)features;
Expand Down
35 changes: 34 additions & 1 deletion CountlyConsentManager.m
Expand Up @@ -18,6 +18,7 @@
CLYConsent const CLYConsentAppleWatch = @"accessory-devices";
CLYConsent const CLYConsentPerformanceMonitoring = @"apm";
CLYConsent const CLYConsentFeedback = @"feedback";
CLYConsent const CLYConsentRemoteConfig = @"remote-config";


@interface CountlyConsentManager ()
Expand All @@ -37,6 +38,7 @@ @implementation CountlyConsentManager
@synthesize consentForAppleWatch = _consentForAppleWatch;
@synthesize consentForPerformanceMonitoring = _consentForPerformanceMonitoring;
@synthesize consentForFeedback = _consentForFeedback;
@synthesize consentForRemoteConfig = _consentForRemoteConfig;

#pragma mark -

Expand Down Expand Up @@ -115,6 +117,9 @@ - (void)giveConsentForFeatures:(NSArray *)features
if ([self containsFeedbackOrStarRating:features] && !self.consentForFeedback)
self.consentForFeedback = YES;

if ([features containsObject:CLYConsentRemoteConfig] && !self.consentForRemoteConfig)
self.consentForRemoteConfig = YES;

[self sendConsentChanges];
}

Expand Down Expand Up @@ -163,6 +168,9 @@ - (void)cancelConsentForFeatures:(NSArray *)features
if ([self containsFeedbackOrStarRating:features] && self.consentForFeedback)
self.consentForFeedback = NO;

if ([features containsObject:CLYConsentRemoteConfig] && self.consentForRemoteConfig)
self.consentForRemoteConfig = NO;

[self sendConsentChanges];
}

Expand Down Expand Up @@ -209,7 +217,8 @@ - (BOOL)hasAnyConsent
self.consentForAttribution ||
self.consentForAppleWatch ||
self.consentForPerformanceMonitoring ||
self.consentForFeedback;
self.consentForFeedback ||
self.consentForRemoteConfig;
}

- (BOOL)containsFeedbackOrStarRating:(NSArray *)features
Expand Down Expand Up @@ -454,6 +463,22 @@ - (void)setConsentForFeedback:(BOOL)consentForFeedback
self.consentChanges[CLYConsentFeedback] = @(consentForFeedback);
}

- (void)setConsentForRemoteConfig:(BOOL)consentForRemoteConfig
{
_consentForRemoteConfig = consentForRemoteConfig;

if (consentForRemoteConfig)
{
COUNTLY_LOG(@"Consent for RemoteConfig is given.");
}
else
{
COUNTLY_LOG(@"Consent for RemoteConfig is cancelled.");
}

self.consentChanges[CLYConsentRemoteConfig] = @(consentForRemoteConfig);
}

#pragma mark -

- (BOOL)consentForSessions
Expand Down Expand Up @@ -553,4 +578,12 @@ - (BOOL)consentForFeedback
return _consentForFeedback;
}

- (BOOL)consentForRemoteConfig
{
if (!self.requiresConsent)
return YES;

return _consentForRemoteConfig;
}

@end

0 comments on commit 16f384b

Please sign in to comment.