Skip to content

Commit

Permalink
updates config to store embedded base url
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Greer committed Nov 7, 2023
1 parent 64a72ca commit d5d8dae
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ public static void initialize(@NonNull Context context, @NonNull String apiKey,
if (sharedInstance.embeddedManager == null) {
sharedInstance.embeddedManager = new IterableEmbeddedManager(
sharedInstance,
sharedInstance.config.embeddedBaseUrl,
null,
null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public class IterableConfig {
*/
final boolean useInMemoryStorageForInApps;

final String embeddedBaseUrl;

private IterableConfig(Builder builder) {
pushIntegrationName = builder.pushIntegrationName;
urlHandler = builder.urlHandler;
Expand All @@ -96,6 +98,7 @@ private IterableConfig(Builder builder) {
allowedProtocols = builder.allowedProtocols;
dataRegion = builder.dataRegion;
useInMemoryStorageForInApps = builder.useInMemoryStorageForInApps;
embeddedBaseUrl = builder.embeddedBaseUrl;
}

public static class Builder {
Expand All @@ -112,7 +115,7 @@ public static class Builder {
private String[] allowedProtocols = new String[0];
private IterableDataRegion dataRegion = IterableDataRegion.US;
private boolean useInMemoryStorageForInApps = false;

private String embeddedBaseUrl = "";
public Builder() {}

/**
Expand Down Expand Up @@ -254,6 +257,12 @@ public Builder setUseInMemoryStorageForInApps(boolean useInMemoryStorageForInApp
return this;
}

@NonNull
public Builder setEmbeddedBaseUrl(@NonNull String embeddedBaseUrl) {
this.embeddedBaseUrl = embeddedBaseUrl;
return this;
}

@NonNull
public IterableConfig build() {
return new IterableConfig(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class IterableEmbeddedManager : IterableActivityMonitor.AppStateCallback
private var actionHandleListeners = mutableListOf<EmbeddedMessageActionHandler>()
private var updateHandleListeners = mutableListOf<EmbeddedMessageUpdateHandler>()
private var iterableApi: IterableApi
private var embeddedBaseUrl: String
private var context: Context

private var embeddedSessionManager = EmbeddedSessionManager()
Expand All @@ -38,10 +39,12 @@ public class IterableEmbeddedManager : IterableActivityMonitor.AppStateCallback
//Constructor of this class with actionHandler and updateHandler
public constructor(
iterableApi: IterableApi,
embeddedBaseUrl: String,
actionHandler: EmbeddedMessageActionHandler?,
updateHandler: EmbeddedMessageUpdateHandler?,
updateHandler: EmbeddedMessageUpdateHandler?
) {
this.iterableApi = iterableApi
this.embeddedBaseUrl = embeddedBaseUrl
this.actionHandler = actionHandler
this.updateHandler = updateHandler
this.context = iterableApi.mainActivityContext
Expand Down Expand Up @@ -151,9 +154,9 @@ public class IterableEmbeddedManager : IterableActivityMonitor.AppStateCallback
})
}

fun handleEmbeddedClick(action: EmbeddedMessageClickAction?, url: String) {
fun handleEmbeddedClick(action: EmbeddedMessageClickAction?) {
actionHandleListeners.forEach {
if(action !== null && action.data.startsWith(url)) {
if(action !== null && action.data.startsWith(this.embeddedBaseUrl)) {

This comment has been minimized.

Copy link
@bradumbaugh

bradumbaugh Nov 7, 2023

Contributor

@evangreer91 It seems to me that it's possible that the app handles some URLs that use a given base URL, but not all URLs that use that base URL. I think it might create more flexibility for client developers if we just let them handle URLs however they need to, in the onTapAction method, without worrying that some URLs get opened for them.

it.onTapAction(action)
} else {
IterableActionRunner.executeAction(context, IterableAction.actionOpenUrl(action?.data), IterableActionSource.EMBEDDED)
Expand Down

0 comments on commit d5d8dae

Please sign in to comment.