Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ public class IterableConfig {
@Nullable
final IterableAPIMobileFrameworkInfo mobileFrameworkInfo;

/**
* Custom notification channel name for push notifications.
* If set, this name will be used for all Iterable notification channels instead of
* deriving the channel name from the sound file name. This prevents non-human-readable
* sound file names from appearing as channel names in the device notification settings.
*/
@Nullable
final String notificationChannelName;

/**
* Base URL for Webview content loading. Specifically used to enable CORS for external resources.
* If null or empty, defaults to empty string (original behavior with about:blank origin).
Expand All @@ -148,6 +157,15 @@ public class IterableConfig {
@Nullable
final String webViewBaseUrl;

/**
* Get the configured notification channel name
* @return Custom notification channel name, or null if not configured
*/
@Nullable
public String getNotificationChannelName() {
return notificationChannelName;
}

/**
* Get the configured WebView base URL
* @return Base URL for WebView content, or null if not configured
Expand Down Expand Up @@ -182,6 +200,7 @@ private IterableConfig(Builder builder) {
iterableUnknownUserHandler = builder.iterableUnknownUserHandler;
decryptionFailureHandler = builder.decryptionFailureHandler;
mobileFrameworkInfo = builder.mobileFrameworkInfo;
notificationChannelName = builder.notificationChannelName;
webViewBaseUrl = builder.webViewBaseUrl;
}

Expand Down Expand Up @@ -210,6 +229,7 @@ public static class Builder {
private int eventThresholdLimit = 100;
private IterableIdentityResolution identityResolution = new IterableIdentityResolution();
private IterableUnknownUserHandler iterableUnknownUserHandler;
private String notificationChannelName;
private String webViewBaseUrl;

public Builder() {}
Expand Down Expand Up @@ -453,6 +473,18 @@ public Builder setMobileFrameworkInfo(@NonNull IterableAPIMobileFrameworkInfo mo
return this;
}

/**
* Set a custom notification channel name for push notifications.
* If set, this name will be used for all Iterable notification channels instead of
* deriving the channel name from the sound file name.
* @param notificationChannelName Custom channel name for notifications
*/
@NonNull
public Builder setNotificationChannelName(@Nullable String notificationChannelName) {
this.notificationChannelName = notificationChannelName;
return this;
}

/**
* Set the base URL for WebView content loading. Used to enable CORS for external resources.
* If not set or null, defaults to empty string (original behavior with about:blank origin).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,21 @@ public IterableNotificationBuilder createNotification(Context context, Bundle ex

soundUri = getSoundUri(context, soundName, soundUrl);

String channelName = (soundUri == Settings.System.DEFAULT_NOTIFICATION_URI)
? getChannelName(context)
: soundName;
// Use custom channel name from config if available, otherwise fall back to sound name
String customChannelName = null;
IterableConfig config = IterableApi.getInstance().config;
if (config != null) {
customChannelName = config.getNotificationChannelName();
}

String channelName;
if (customChannelName != null && !customChannelName.isEmpty()) {
channelName = customChannelName;
} else if (soundUri == Settings.System.DEFAULT_NOTIFICATION_URI) {
channelName = getChannelName(context);
} else {
channelName = soundName;
}

String channelId = (soundUri == Settings.System.DEFAULT_NOTIFICATION_URI)
? context.getPackageName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,19 @@ class IterableConfigTest {
val config: IterableConfig = configBuilder.build()
assertFalse(config.keychainEncryption)
}

@Test
fun defaultNotificationChannelName() {
val configBuilder: IterableConfig.Builder = IterableConfig.Builder()
val config: IterableConfig = configBuilder.build()
assertThat(config.notificationChannelName, `is`(nullValue()))
}

@Test
fun setNotificationChannelName() {
val configBuilder: IterableConfig.Builder = IterableConfig.Builder()
.setNotificationChannelName("My App Notifications")
val config: IterableConfig = configBuilder.build()
assertThat(config.notificationChannelName, `is`("My App Notifications"))
}
}
Loading