diff --git a/Sources/mParticle-Appboy/MPKitAppboy.m b/Sources/mParticle-Appboy/MPKitAppboy.m index 18bf6db..65f0384 100644 --- a/Sources/mParticle-Appboy/MPKitAppboy.m +++ b/Sources/mParticle-Appboy/MPKitAppboy.m @@ -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 inAppMessageControllerDelegate = nil; static BOOL shouldDisableNotificationHandling = NO; @@ -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; } @@ -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 *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 { diff --git a/mParticle-Appboy.podspec b/mParticle-Appboy.podspec index 7951b0e..fdd03ba 100755 --- a/mParticle-Appboy.podspec +++ b/mParticle-Appboy.podspec @@ -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