Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Commit 1683244

Browse files
authored
Merge pull request #45 from googleads/1.0.4
Changed logic for re-consent prompts. Updated to 1.0.4
2 parents be515ed + 38779c0 commit 1683244

File tree

12 files changed

+24
-22
lines changed

12 files changed

+24
-22
lines changed

PersonalizedAdConsent/PersonalizedAdConsent/Info.plist

100755100644
File mode changed.

PersonalizedAdConsent/PersonalizedAdConsent/PACConsentForm.h

100755100644
File mode changed.

PersonalizedAdConsent/PersonalizedAdConsent/PACConsentForm.m

100755100644
File mode changed.

PersonalizedAdConsent/PersonalizedAdConsent/PACError.h

100755100644
File mode changed.

PersonalizedAdConsent/PersonalizedAdConsent/PACError.m

100755100644
File mode changed.

PersonalizedAdConsent/PersonalizedAdConsent/PACPersonalizedAdConsent.h

100755100644
File mode changed.

PersonalizedAdConsent/PersonalizedAdConsent/PACPersonalizedAdConsent.m

100755100644
Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ @interface PACAdProvider ()
2929
- (nullable instancetype)initWithDictionary:(nullable NSDictionary<NSString *, id> *)dictionary;
3030
@end
3131

32-
NSString *const PACVersionString = @"1.0.3";
32+
NSString *const PACVersionString = @"1.0.4";
3333
NSString *const PACUserDefaultsRootKey = @"personalized_ad_status";
3434

3535
static NSString *const PACInfoUpdateURLFormat =
@@ -80,8 +80,8 @@ static PACConsentStatus PACConsentStatusForStatusString(NSString *_Nullable stat
8080
}
8181

8282
/// Returns an array of ad provider dictionary representations for the provided ad providers.
83-
static NSArray<NSDictionary *> *_Nonnull
84-
PACSerializeAdProviders(NSOrderedSet<PACAdProvider *> *_Nullable providers) {
83+
static NSArray<NSDictionary *> *_Nonnull PACSerializeAdProviders(
84+
NSOrderedSet<PACAdProvider *> *_Nullable providers) {
8585
NSMutableArray<NSDictionary *> *serializedProviders = [[NSMutableArray alloc] init];
8686
for (PACAdProvider *provider in providers) {
8787
[serializedProviders addObject:provider.dictionaryRepresentation];
@@ -91,8 +91,8 @@ static PACConsentStatus PACConsentStatusForStatusString(NSString *_Nullable stat
9191

9292
/// Returns an ordered set of ad providers for the provided array of ad provider dictionary
9393
/// representations.
94-
static NSOrderedSet<PACAdProvider *> *_Nonnull
95-
PACDeserializeAdProviders(NSArray<NSDictionary *> *_Nullable serializedProviders) {
94+
static NSOrderedSet<PACAdProvider *> *_Nonnull PACDeserializeAdProviders(
95+
NSArray<NSDictionary *> *_Nullable serializedProviders) {
9696
NSMutableOrderedSet *adProviders = [[NSMutableOrderedSet alloc] init];
9797
for (NSDictionary<NSString *, id> *providerInfo in serializedProviders) {
9898
PACAdProvider *provider = [[PACAdProvider alloc] initWithDictionary:providerInfo];
@@ -122,15 +122,15 @@ - (nullable instancetype)initWithDictionary:(nullable NSDictionary<NSString *, i
122122
}
123123

124124
- (NSUInteger)hash {
125-
return _dictionaryRepresentation.hash;
125+
return _identifier.hash;
126126
}
127127

128128
- (BOOL)isEqual:(nullable id)object {
129129
if (![object isKindOfClass:[PACAdProvider class]]) {
130130
return NO;
131131
}
132132
PACAdProvider *other = object;
133-
return [_dictionaryRepresentation isEqual:other.dictionaryRepresentation];
133+
return [self.identifier isEqual:other.identifier];
134134
}
135135

136136
@end
@@ -244,7 +244,7 @@ - (void)writeStatusToUserDefaults {
244244
PACStoreKeyTaggedForUnderAgeOfConsent : _tagForUnderAgeOfConsent ? @1 : @0,
245245
PACStoreKeyIsRequestInEEAOrUnknown : _isRequestInEEAOrUnknown ? @1 : @0,
246246
PACStoreKeyHasAnyNonPersonalizedPublisherIdentifier :
247-
_hasAnyNonPersonalizedPublisherIdentifier ? @1 : @0,
247+
_hasAnyNonPersonalizedPublisherIdentifier ? @1 : @0,
248248
PACStoreKeyConsentStatus : PACConsentStatusStringForStatus(_status),
249249
PACStoreKeyPublisherIdentifiers : _publisherIdentifiers.allObjects ?: @[],
250250
PACStoreKeyProviders : PACSerializeAdProviders(_adProviders),
@@ -330,8 +330,9 @@ - (void)requestConsentInfoUpdateForPublisherIdentifiers:
330330
return;
331331
}
332332

333-
NSDictionary<NSString *, id> *info =
334-
[NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
333+
NSDictionary<NSString *, id> *info = [NSJSONSerialization JSONObjectWithData:data
334+
options:0
335+
error:&error];
335336
if (error || ![info isKindOfClass:[NSDictionary class]]) {
336337
if (!error) {
337338
error = PACErrorWithDescription(@"Invalid response.");
@@ -340,8 +341,8 @@ - (void)requestConsentInfoUpdateForPublisherIdentifiers:
340341
return;
341342
}
342343

343-
NSString *responseString =
344-
[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
344+
NSString *responseString = [[NSString alloc] initWithData:data
345+
encoding:NSUTF8StringEncoding];
345346

346347
dispatch_async(dispatch_get_main_queue(), ^{
347348
[self handleInfoUpdateResponse:publisherIdentifiers
@@ -464,9 +465,10 @@ - (void)handleInfoUpdateResponse:(nonnull NSArray<NSString *> *)publisherIdentif
464465

465466
BOOL nonPersonalizedOnlyValueChanged =
466467
_hasAnyNonPersonalizedPublisherIdentifier != previousHasAnyNonPersonalizedPublisherIdentifier;
467-
BOOL providersMatchesConsentedProviders = [_consentedProviders.set isEqual:_adProviders.set];
468+
BOOL consentedProvidersContainsProviders =
469+
[_adProviders.set isSubsetOfSet:_consentedProviders.set];
468470
if (_isRequestInEEAOrUnknown &&
469-
(!providersMatchesConsentedProviders || nonPersonalizedOnlyValueChanged)) {
471+
(!consentedProvidersContainsProviders || nonPersonalizedOnlyValueChanged)) {
470472
_consentedProviders = nil;
471473
_status = PACConsentStatusUnknown;
472474
}

PersonalizedAdConsent/PersonalizedAdConsent/PACView.h

100755100644
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
#import "PACConsentForm.h"
1818

1919
typedef NSString *PACFormKey NS_STRING_ENUM;
20-
static PACFormKey const PACFormKeyOfferPersonalized = @"offer_personalized";
21-
static PACFormKey const PACFormKeyOfferNonPersonalized = @"offer_non_personalized";
22-
static PACFormKey const PACFormKeyOfferAdFree = @"offer_ad_free";
23-
static PACFormKey const PACFormKeyAppPrivacyPolicyURLString = @"app_privacy_url";
24-
static PACFormKey const PACFormKeyConstentInfo = @"consent_info";
25-
static PACFormKey const PACFormKeyAppName = @"app_name";
26-
static PACFormKey const PACFormKeyAppIcon = @"app_icon";
27-
static PACFormKey const PACFormKeyPlatform = @"plat";
20+
static PACFormKey _Nonnull const PACFormKeyOfferPersonalized = @"offer_personalized";
21+
static PACFormKey _Nonnull const PACFormKeyOfferNonPersonalized = @"offer_non_personalized";
22+
static PACFormKey _Nonnull const PACFormKeyOfferAdFree = @"offer_ad_free";
23+
static PACFormKey _Nonnull const PACFormKeyAppPrivacyPolicyURLString = @"app_privacy_url";
24+
static PACFormKey _Nonnull const PACFormKeyConstentInfo = @"consent_info";
25+
static PACFormKey _Nonnull const PACFormKeyAppName = @"app_name";
26+
static PACFormKey _Nonnull const PACFormKeyAppIcon = @"app_icon";
27+
static PACFormKey _Nonnull const PACFormKeyPlatform = @"plat";
2828

2929
/// Loads and displays the consent form.
3030
@interface PACView : UIView<UIWebViewDelegate>

PersonalizedAdConsent/PersonalizedAdConsent/PACView.m

100755100644
File mode changed.

PersonalizedAdConsent/PersonalizedAdConsent/PersonalizedAdConsent.bundle/consentform.html

100755100644
File mode changed.

0 commit comments

Comments
 (0)