Skip to content

Commit

Permalink
feat: Added support for custom domain (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngarg-mparticle authored Apr 18, 2024
1 parent 7d7335b commit a1ba7a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/kotlin/com/mparticle/kits/MParticleAutopilot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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"

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class UrbanAirshipConfiguration(settings: Map<String, String>) {
val applicationKey: String?
val applicationSecret: String?
val domain: String?
val customDomainProxyUrl: String?
val enableTags: Boolean
val includeUserAttributes: Boolean
val userIdField: IdentityType?
Expand Down Expand Up @@ -67,6 +68,7 @@ class UrbanAirshipConfiguration(settings: Map<String, String>) {
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"
Expand Down Expand Up @@ -95,6 +97,11 @@ class UrbanAirshipConfiguration(settings: Map<String, String>) {
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)) {
Expand Down

0 comments on commit a1ba7a4

Please sign in to comment.