From a1ba7a43abb7ea9d943529bb1d8f1196669132c6 Mon Sep 17 00:00:00 2001 From: ngarg-mparticle <113475342+ngarg-mparticle@users.noreply.github.com> Date: Thu, 18 Apr 2024 09:28:15 -0700 Subject: [PATCH] feat: Added support for custom domain (#184) --- src/main/kotlin/com/mparticle/kits/MParticleAutopilot.kt | 7 +++++++ .../kotlin/com/mparticle/kits/UrbanAirshipConfiguration.kt | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/kotlin/com/mparticle/kits/MParticleAutopilot.kt b/src/main/kotlin/com/mparticle/kits/MParticleAutopilot.kt index dbe8d73..73642aa 100644 --- a/src/main/kotlin/com/mparticle/kits/MParticleAutopilot.kt +++ b/src/main/kotlin/com/mparticle/kits/MParticleAutopilot.kt @@ -35,6 +35,11 @@ class MParticleAutopilot : Autopilot() { if ("EU".equals(preferences.getString(DOMAIN, null), true)) { optionsBuilder.setSite(AirshipConfigOptions.SITE_EU) } + val customDomain = preferences.getString(CUSTOM_DOMAIN_PROXY_URL, null) + if (!UAStringUtil.isEmpty(customDomain)) { + optionsBuilder.setInitialConfigUrl(customDomain) + .setUrlAllowList(arrayOf(customDomain)) + } return optionsBuilder.build() } @@ -72,6 +77,7 @@ class MParticleAutopilot : Autopilot() { private const val APP_KEY = "applicationKey" private const val APP_SECRET = "applicationSecret" private const val DOMAIN = "domain" + private const val CUSTOM_DOMAIN_PROXY_URL = "customDomainProxyUrl" private const val NOTIFICATION_ICON_NAME = "notificationIconName" private const val NOTIFICATION_COLOR = "notificationColor" @@ -90,6 +96,7 @@ class MParticleAutopilot : Autopilot() { .putString(APP_KEY, configuration.applicationKey) .putString(APP_SECRET, configuration.applicationSecret) .putString(DOMAIN, configuration.domain) + .putString(CUSTOM_DOMAIN_PROXY_URL, configuration.customDomainProxyUrl) // Convert accent color hex string to an int val accentColor = configuration.notificationColor diff --git a/src/main/kotlin/com/mparticle/kits/UrbanAirshipConfiguration.kt b/src/main/kotlin/com/mparticle/kits/UrbanAirshipConfiguration.kt index 5a0012b..31fe776 100644 --- a/src/main/kotlin/com/mparticle/kits/UrbanAirshipConfiguration.kt +++ b/src/main/kotlin/com/mparticle/kits/UrbanAirshipConfiguration.kt @@ -10,6 +10,7 @@ class UrbanAirshipConfiguration(settings: Map) { val applicationKey: String? val applicationSecret: String? val domain: String? + val customDomainProxyUrl: String? val enableTags: Boolean val includeUserAttributes: Boolean val userIdField: IdentityType? @@ -67,6 +68,7 @@ class UrbanAirshipConfiguration(settings: Map) { private const val KEY_APP_KEY = "applicationKey" private const val KEY_APP_SECRET = "applicationSecret" private const val KEY_DOMAIN = "domain" + private const val KEY_CUSTOM_DOMAIN_PROXY_URL = "customDomainProxyUrl" private const val KEY_ENABLE_TAGS = "enableTags" private const val KEY_USER_ID_FIELD = "namedUserIdField" private const val KEY_EVENT_USER_TAGS = "eventUserTags" @@ -95,6 +97,11 @@ class UrbanAirshipConfiguration(settings: Map) { applicationKey = settings[KEY_APP_KEY] applicationSecret = settings[KEY_APP_SECRET] domain = settings[KEY_DOMAIN] + if (settings.containsKey(KEY_CUSTOM_DOMAIN_PROXY_URL)) { + customDomainProxyUrl = settings[KEY_CUSTOM_DOMAIN_PROXY_URL] + } else { + customDomainProxyUrl = null + } enableTags = KitUtils.parseBooleanSetting(settings, KEY_ENABLE_TAGS, true) userIdField = parseNamedUserIdentityType(settings[KEY_USER_ID_FIELD]) if (settings.containsKey(KEY_EVENT_USER_TAGS)) {