-
Notifications
You must be signed in to change notification settings - Fork 37
feat: Remove BrazeKitCompat, migrate to pure BrazeKit #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,11 +2,9 @@ | |
|
|
||
| #if TARGET_OS_IOS | ||
| @import BrazeKit; | ||
| @import BrazeKitCompat; | ||
| @import BrazeUI; | ||
| #else | ||
| @import BrazeKit; | ||
| @import BrazeKitCompat; | ||
| #endif | ||
|
|
||
| static NSString *const eabAPIKey = @"apiKey"; | ||
|
|
@@ -60,6 +58,14 @@ | |
| static NSString *const BGoogleAdUserDataKey = @"$google_ad_user_data"; | ||
| static NSString *const BGoogleAdPersonalizationKey = @"$google_ad_personalization"; | ||
|
|
||
| // Braze configuration option keys (replaces BrazeKitCompat ABK* constants for Full Migration) | ||
|
rmi22186 marked this conversation as resolved.
Outdated
|
||
| static NSString *const kMPBrazeConfigEndpoint = @"endpoint"; | ||
| static NSString *const kMPBrazeConfigRequestPolicy = @"requestPolicy"; | ||
| static NSString *const kMPBrazeConfigFlushInterval = @"flushInterval"; | ||
| static NSString *const kMPBrazeConfigSessionTimeout = @"sessionTimeout"; | ||
| static NSString *const kMPBrazeConfigTriggerMinimumTimeInterval = @"triggerMinimumTimeInterval"; | ||
| static NSString *const kMPBrazeConfigAutomaticLocationCollection = @"automaticLocationCollection"; | ||
|
|
||
| #if TARGET_OS_IOS | ||
| static id<BrazeInAppMessageUIDelegate> inAppMessageControllerDelegate = nil; | ||
| static BOOL shouldDisableNotificationHandling = NO; | ||
|
|
@@ -371,20 +377,20 @@ - (id const)providerKitInstance { | |
| - (void)start { | ||
| if (!self->appboyInstance) { | ||
| NSDictionary *optionsDict = [self optionsDictionary]; | ||
| BRZConfiguration *configuration = [[BRZConfiguration alloc] initWithApiKey:self.configuration[eabAPIKey] endpoint:optionsDict[ABKEndpointKey]]; | ||
| BRZConfiguration *configuration = [[BRZConfiguration alloc] initWithApiKey:self.configuration[eabAPIKey] endpoint:optionsDict[kMPBrazeConfigEndpoint]]; | ||
|
|
||
| [configuration.api addSDKMetadata:@[BRZSDKMetadata.mparticle]]; | ||
| configuration.api.sdkFlavor = ((NSNumber *)optionsDict[ABKSDKFlavorKey]).intValue; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sdkFlavor is removed because we already have
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We actually still have references to Can you add a line to continue sending the flavor to Braze:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good. I'll add these back |
||
| configuration.api.requestPolicy = ((NSNumber *)optionsDict[ABKRequestProcessingPolicyOptionKey]).intValue; | ||
| NSNumber *flushIntervalOption = (NSNumber *)optionsDict[ABKFlushIntervalOptionKey] ?: @10; // If not set, use the default 10 seconds specified in Braze SDK header | ||
| configuration.api.sdkFlavor = BRZSDKFlavorMparticle; | ||
| configuration.api.requestPolicy = ((NSNumber *)optionsDict[kMPBrazeConfigRequestPolicy]).intValue; | ||
| NSNumber *flushIntervalOption = (NSNumber *)optionsDict[kMPBrazeConfigFlushInterval] ?: @10; // If not set, use the default 10 seconds specified in Braze SDK header | ||
| configuration.api.flushInterval = flushIntervalOption.doubleValue < 1.0 ? 1.0 : flushIntervalOption.doubleValue; // Ensure value is above the minimum of 1.0 per run time warning from Braze SDK | ||
| configuration.api.trackingPropertyAllowList = brazeTrackingPropertyAllowList; | ||
|
|
||
| configuration.sessionTimeout = ((NSNumber *)optionsDict[ABKSessionTimeoutKey]).doubleValue; | ||
| configuration.sessionTimeout = ((NSNumber *)optionsDict[kMPBrazeConfigSessionTimeout]).doubleValue; | ||
|
|
||
| configuration.triggerMinimumTimeInterval = ((NSNumber *)optionsDict[ABKMinimumTriggerTimeIntervalKey]).doubleValue; | ||
| configuration.triggerMinimumTimeInterval = ((NSNumber *)optionsDict[kMPBrazeConfigTriggerMinimumTimeInterval]).doubleValue; | ||
|
|
||
| NSNumber *automaticLocationTrackingOption = (NSNumber *)optionsDict[ABKEnableAutomaticLocationCollectionKey]; | ||
| NSNumber *automaticLocationTrackingOption = (NSNumber *)optionsDict[kMPBrazeConfigAutomaticLocationCollection]; | ||
| if (automaticLocationTrackingOption != nil && automaticLocationTrackingOption.boolValue && brazeLocationProvider) { | ||
| configuration.location.automaticLocationCollection = YES; | ||
| configuration.location.brazeLocationProvider = brazeLocationProvider; | ||
|
|
@@ -444,8 +450,9 @@ - (void)stop { | |
| } | ||
|
|
||
| - (NSMutableDictionary<NSString *, NSObject *> *)optionsDictionary { | ||
| // This maps the mParticle keys (prefixed with ABK) to the Braze Swift SDK configuration keys (prefixed with kMPBrazeConfig) | ||
| NSArray <NSString *> *serverKeys = @[@"ABKRequestProcessingPolicyOptionKey", @"ABKFlushIntervalOptionKey", @"ABKSessionTimeoutKey", @"ABKMinimumTriggerTimeIntervalKey"]; | ||
|
rmi22186 marked this conversation as resolved.
|
||
| NSArray <NSString *> *appboyKeys = @[ABKRequestProcessingPolicyOptionKey, ABKFlushIntervalOptionKey, ABKSessionTimeoutKey, ABKMinimumTriggerTimeIntervalKey]; | ||
| NSArray <NSString *> *configKeys = @[kMPBrazeConfigRequestPolicy, kMPBrazeConfigFlushInterval, kMPBrazeConfigSessionTimeout, kMPBrazeConfigTriggerMinimumTimeInterval]; | ||
| NSMutableDictionary<NSString *, NSObject *> *optionsDictionary = [[NSMutableDictionary alloc] initWithCapacity:serverKeys.count]; | ||
| NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; | ||
| numberFormatter.numberStyle = NSNumberFormatterNoStyle; | ||
|
|
@@ -454,42 +461,31 @@ - (void)stop { | |
| NSString *optionValue = self.configuration[serverKey]; | ||
|
|
||
| if (optionValue != nil && (NSNull *)optionValue != [NSNull null]) { | ||
| NSString *appboyKey = appboyKeys[idx]; | ||
| NSNumber *numberValue = nil; | ||
| @try { | ||
| numberValue = [numberFormatter numberFromString:optionValue]; | ||
| } @catch (NSException *exception) { | ||
| numberValue = nil; | ||
| } | ||
| if (numberValue != nil) { | ||
| optionsDictionary[appboyKey] = numberValue; | ||
| optionsDictionary[configKeys[idx]] = numberValue; | ||
| } | ||
| } | ||
| }]; | ||
|
|
||
| if (self.host.length) { | ||
| #pragma clang diagnostic push | ||
| #pragma clang diagnostic ignored "-Wincompatible-pointer-types" | ||
| optionsDictionary[ABKEndpointKey] = self.host; | ||
| #pragma clang diagnostic pop | ||
| optionsDictionary[kMPBrazeConfigEndpoint] = self.host; | ||
| } | ||
|
|
||
| if (optionsDictionary.count == 0) { | ||
| #pragma clang diagnostic push | ||
| #pragma clang diagnostic ignored "-Wincompatible-pointer-types" | ||
| optionsDictionary = [[NSMutableDictionary alloc] initWithCapacity:serverKeys.count]; | ||
| } | ||
| optionsDictionary[ABKSDKFlavorKey] = @(MPARTICLE); | ||
| #pragma clang diagnostic pop | ||
|
|
||
|
|
||
| #if TARGET_OS_IOS | ||
| optionsDictionary[ABKEnableAutomaticLocationCollectionKey] = @(YES); | ||
| optionsDictionary[kMPBrazeConfigAutomaticLocationCollection] = @(YES); | ||
| if (self.configuration[@"ABKDisableAutomaticLocationCollectionKey"]) { | ||
|
rmi22186 marked this conversation as resolved.
|
||
| if ([self.configuration[@"ABKDisableAutomaticLocationCollectionKey"] caseInsensitiveCompare:@"true"] == NSOrderedSame) { | ||
| #pragma clang diagnostic push | ||
| #pragma clang diagnostic ignored "-Wincompatible-pointer-types" | ||
| optionsDictionary[ABKEnableAutomaticLocationCollectionKey] = @(NO); | ||
| #pragma clang diagnostic pop | ||
| optionsDictionary[kMPBrazeConfigAutomaticLocationCollection] = @(NO); | ||
| } | ||
| } | ||
| #endif | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this next release be a minor version (8.15.0) due to adding a backward-compatible feature when following SemVer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to 8.15.0