Skip to content

Commit 447b1c5

Browse files
committed
Update privacy consent API names and no public getters
* Rename `requiresPrivacyConsent` to `consentRequired` * Rename `privacyConsent` to `consentGiven` * Remove public getters for these 2 properties * Swift cannot have computed write-only properties so instead of `OneSignal.consentGiven = true`, it will be `OneSignal.setConsentGiven(true)`
1 parent bc33bc4 commit 447b1c5

File tree

8 files changed

+65
-93
lines changed

8 files changed

+65
-93
lines changed

iOS_SDK/OneSignalDevApp/OneSignalDevApp/Base.lproj/Main.storyboard

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

iOS_SDK/OneSignalDevApp/OneSignalDevApp/ViewController.m

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ - (void)viewDidLoad {
4040

4141
self.activityIndicatorView.hidden = true;
4242

43-
self.consentSegmentedControl.selectedSegmentIndex = (NSInteger) ![OneSignal requiresPrivacyConsent];
44-
4543
self.subscriptionSegmentedControl.selectedSegmentIndex = (NSInteger) OneSignal.User.pushSubscription.optedIn;
4644

4745
self.locationSharedSegementedControl.selectedSegmentIndex = (NSInteger) [OneSignal.Location isShared];
@@ -168,7 +166,7 @@ - (void)didReceiveMemoryWarning {
168166

169167
- (IBAction)consentSegmentedControlValueChanged:(UISegmentedControl *)sender {
170168
NSLog(@"View controller consent granted: %i", (int) sender.selectedSegmentIndex);
171-
[OneSignal setPrivacyConsent:(bool) sender.selectedSegmentIndex];
169+
[OneSignal setConsentGiven:(bool) sender.selectedSegmentIndex];
172170
}
173171

174172
- (IBAction)subscriptionSegmentedControlValueChanged:(UISegmentedControl *)sender {
@@ -267,13 +265,13 @@ - (IBAction)clearAllNotifications:(id)sender {
267265
}
268266

269267
- (IBAction)requireConsent:(id)sender {
270-
NSLog(@"Dev App: setting setRequiresPrivacyConsent to true.");
271-
[OneSignal setRequiresPrivacyConsent:true];
268+
NSLog(@"Dev App: setting setConsentRequired to true.");
269+
[OneSignal setConsentRequired:true];
272270
}
273271

274272
- (IBAction)dontRequireConsent:(id)sender {
275-
NSLog(@"Dev App: setting setRequiresPrivacyConsent to false.");
276-
[OneSignal setRequiresPrivacyConsent:false];
273+
NSLog(@"Dev App: setting setConsentRequired to false.");
274+
[OneSignal setConsentRequired:false];
277275
}
278276

279277
@end

iOS_SDK/OneSignalDevApp/OneSignalDevAppClip/ViewController.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ - (void)viewDidLoad {
3939

4040
self.activityIndicatorView.hidden = true;
4141

42-
self.consentSegmentedControl.selectedSegmentIndex = (NSInteger) ![OneSignal requiresPrivacyConsent];
43-
4442
// self.subscriptionSegmentedControl.selectedSegmentIndex = (NSInteger) OneSignal.getDeviceState.isSubscribed;
4543

4644
self.locationSharedSegementedControl.selectedSegmentIndex = (NSInteger) [OneSignal.Location isShared];
@@ -128,7 +126,7 @@ - (void)didReceiveMemoryWarning {
128126

129127
- (IBAction)consentSegmentedControlValueChanged:(UISegmentedControl *)sender {
130128
NSLog(@"View controller consent granted: %i", (int) sender.selectedSegmentIndex);
131-
[OneSignal setPrivacyConsent:(bool) sender.selectedSegmentIndex];
129+
[OneSignal setConsentGiven:(bool) sender.selectedSegmentIndex];
132130
}
133131

134132
- (IBAction)subscriptionSegmentedControlValueChanged:(UISegmentedControl *)sender {

iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSPrivacyConsentController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ + (void)setRequiresPrivacyConsent:(BOOL)required {
4343
return;
4444

4545
if ([self requiresUserPrivacyConsent] && !required) {
46-
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Cannot change requiresUserPrivacyConsent() from TRUE to FALSE"];
46+
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Cannot change setConsentRequired() from TRUE to FALSE"];
4747
return;
4848
}
4949
[OneSignalUserDefaults.initShared saveBoolForKey:OSUD_REQUIRES_USER_PRIVACY_CONSENT withValue:required];

iOS_SDK/OneSignalSDK/Source/OneSignal.m

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ + (void)init {
511511
// using classes as delegates is not best practice. We should consider using a shared instance of a class instead
512512
[OSSessionManager sharedSessionManager].delegate = (id<SessionStatusDelegate>)self;
513513

514-
if ([self requiresPrivacyConsent]) {
514+
if ([OSPrivacyConsentController requiresUserPrivacyConsent]) {
515515
[self delayInitializationForPrivacyConsent];
516516
return;
517517
}
@@ -602,15 +602,11 @@ + (void)registerForAPNsToken {
602602
}
603603
}
604604

605-
+ (void)setRequiresPrivacyConsent:(BOOL)required {
605+
+ (void)setConsentRequired:(BOOL)required {
606606
[OSPrivacyConsentController setRequiresPrivacyConsent:required];
607607
}
608608

609-
+ (BOOL)requiresPrivacyConsent {
610-
return [OSPrivacyConsentController requiresUserPrivacyConsent];
611-
}
612-
613-
+ (void)setPrivacyConsent:(BOOL)granted {
609+
+ (void)setConsentGiven:(BOOL)granted {
614610
[OSPrivacyConsentController consentGranted:granted];
615611

616612
if (!granted || !delayedInitializationForPrivacyConsent || _delayedInitParameters == nil)

iOS_SDK/OneSignalSDK/Source/OneSignalFramework.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,12 @@ NS_SWIFT_NAME(login(externalId:token:));
9292
+ (Class<OSDebug>)Debug NS_REFINED_FOR_SWIFT;
9393

9494
#pragma mark Privacy Consent
95-
+ (void)setPrivacyConsent:(BOOL)granted NS_REFINED_FOR_SWIFT;
96-
+ (BOOL)getPrivacyConsent NS_REFINED_FOR_SWIFT;
9795
/**
98-
* Tells your application if privacy consent is still needed from the current device.
96+
* Set to `true` if your application requires privacy consent.
9997
* Consent should be provided prior to the invocation of `initialize` to ensure compliance.
10098
*/
101-
+ (BOOL)requiresPrivacyConsent NS_REFINED_FOR_SWIFT;
102-
+ (void)setRequiresPrivacyConsent:(BOOL)required NS_REFINED_FOR_SWIFT;
99+
+ (void)setConsentRequired:(BOOL)required;
100+
+ (void)setConsentGiven:(BOOL)granted;
103101

104102
#pragma mark In-App Messaging
105103
+ (Class<OSInAppMessages>)InAppMessages NS_REFINED_FOR_SWIFT;

iOS_SDK/OneSignalSDK/Source/OneSignalSwiftInterface.swift

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,7 @@ public extension OneSignal {
5858

5959
static var LiveActivities: OSLiveActivities.Type {
6060
return __liveActivities()
61-
}
62-
63-
static var requiresPrivacyConsent: Bool {
64-
get {
65-
return __requiresPrivacyConsent()
66-
}
67-
set {
68-
__setRequiresPrivacyConsent(newValue)
69-
}
70-
}
71-
72-
static var privacyConsent: Bool {
73-
get {
74-
return __getPrivacyConsent()
75-
}
76-
set {
77-
__setPrivacyConsent(newValue)
78-
}
79-
}
61+
}
8062
}
8163

8264
public extension OSDebug {

iOS_SDK/OneSignalSDK/Source/OneSignalTracker.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ + (void)endBackgroundFocusTask {
7979

8080
+ (void)onFocus:(BOOL)toBackground {
8181
// return if the user has not granted privacy permissions
82-
if ([OneSignal requiresPrivacyConsent])
82+
if ([OSPrivacyConsentController requiresUserPrivacyConsent])
8383
return;
8484

8585
// Prevent the onFocus to be called twice when app being terminated

0 commit comments

Comments
 (0)