Skip to content
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

feat: Added support for custom domain #184

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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