Skip to content

Commit

Permalink
feat: Implement Google EU Consent
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonStalnaker committed Sep 4, 2024
1 parent d741bb6 commit a81c44f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
30 changes: 30 additions & 0 deletions Sources/mParticle-Appboy/MPKitAppboy.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
static NSString *const promotionKey = @"promotions";
static NSString *const impressionKey = @"impressions";

// Strings used for Google Consent
static NSString *const MPGoogleAdUserDataKey = @"google_ad_user_data";
static NSString *const MPGoogleAdPersonalizationKey = @"google_ad_personalization";
static NSString *const BGoogleAdUserDataKey = @"$google_ad_user_data";
static NSString *const BGoogleAdPersonalizationKey = @"$google_ad_personalization";

#if TARGET_OS_IOS
static id<BrazeInAppMessageUIDelegate> inAppMessageControllerDelegate = nil;
static BOOL shouldDisableNotificationHandling = NO;
Expand Down Expand Up @@ -325,6 +331,9 @@ - (MPKitExecStatus *)didFinishLaunchingWithConfiguration:(NSDictionary *)configu
_started = NO;
}

// Update Consent on launch
[self updateConsent];

execStatus = [[MPKitExecStatus alloc] initWithSDKCode:[[self class] kitCode] returnCode:MPKitReturnCodeSuccess];
return execStatus;
}
Expand Down Expand Up @@ -1037,6 +1046,27 @@ - (MPKitExecStatus *)setATTStatus:(MPATTAuthorizationStatus)status withATTStatus
return [[MPKitExecStatus alloc] initWithSDKCode:@(MPKitInstanceAppboy) returnCode:MPKitReturnCodeSuccess];
}

- (MPKitExecStatus *)setConsentState:(nullable MPConsentState *)state {
[self updateConsent];

return [[MPKitExecStatus alloc] initWithSDKCode:@(MPKitInstanceAppboy) returnCode:MPKitReturnCodeSuccess];
}

- (void)updateConsent {
MParticleUser *currentUser = [[[MParticle sharedInstance] identity] currentUser];
NSDictionary<NSString *, MPGDPRConsent *> *userConsentMap = currentUser.consentState.gdprConsentState;

// Update from mParticle consent
if (self.configuration[MPGoogleAdUserDataKey] && userConsentMap[self.configuration[MPGoogleAdUserDataKey]]) {
MPGDPRConsent *consent = userConsentMap[self.configuration[MPGoogleAdUserDataKey]];
[appboyInstance.user setCustomAttributeWithKey:BGoogleAdUserDataKey boolValue:consent.consented];
}
if (self.configuration[MPGoogleAdPersonalizationKey] && userConsentMap[self.configuration[MPGoogleAdPersonalizationKey]]) {
MPGDPRConsent *consent = userConsentMap[self.configuration[MPGoogleAdPersonalizationKey]];
[appboyInstance.user setCustomAttributeWithKey:BGoogleAdPersonalizationKey boolValue:consent.consented];
}
}

#pragma mark Configuration Dictionary

- (NSMutableDictionary *)simplifiedDictionary:(NSDictionary *)originalDictionary {
Expand Down
10 changes: 5 additions & 5 deletions mParticle-Appboy.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ Pod::Spec.new do |s|
s.ios.source_files = 'Sources/**/*.{h,m,mm}'
s.ios.resource_bundles = { 'mParticle-Appboy-Privacy' => ['Sources/mParticle-Appboy/PrivacyInfo.xcprivacy'] }
s.ios.dependency 'mParticle-Apple-SDK', '~> 8.19'
s.ios.dependency 'BrazeKit', '~> 9.0'
s.ios.dependency 'BrazeKitCompat', '~> 9.0'
s.ios.dependency 'BrazeUI', '~> 9.0'
s.ios.dependency 'BrazeKit', '~> 10.0'
s.ios.dependency 'BrazeKitCompat', '~> 10.0'
s.ios.dependency 'BrazeUI', '~> 10.0'

s.tvos.deployment_target = "12.0"
s.tvos.source_files = 'Sources/**/*.{h,m,mm}'
s.tvos.resource_bundles = { 'mParticle-Appboy-Privacy' => ['Sources/mParticle-Appboy/PrivacyInfo.xcprivacy'] }
s.tvos.dependency 'mParticle-Apple-SDK', '~> 8.19'
s.tvos.dependency 'BrazeKit', '~> 9.0'
s.tvos.dependency 'BrazeKitCompat', '~> 9.0'
s.tvos.dependency 'BrazeKit', '~> 10.0'
s.tvos.dependency 'BrazeKitCompat', '~> 10.0'


end

0 comments on commit a81c44f

Please sign in to comment.