Skip to content

Commit c4f1591

Browse files
adds getApiEndpoint function for redirecting
1 parent 0042229 commit c4f1591

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

sample-apps/swiftui-sample-app/swiftui-sample-app/IterableHelper.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import IterableSDK
88
class IterableHelper {
99
// Please replace with your API key
1010
#error("Please add your API Key here")
11-
private static let apiKey = ""
11+
private static let apiKey = "1d38cefe0f08466e8d87ac1e80363c82"
1212

1313
static func initialize(launchOptions: [UIApplication.LaunchOptionsKey : Any]?) {
1414
let config = IterableConfig()
1515
// urlDelegate and customActionDelegate must be strong references
1616
// otherwise they will be deallocated
1717
config.urlDelegate = urlDelegate
1818
config.customActionDelegate = customActionDelegate
19+
config.dataRegion = IterableDataRegion.EU
1920
IterableAPI.initialize(apiKey: apiKey,
2021
launchOptions: launchOptions,
2122
config: config)

swift-sdk/Internal/InternalIterableAPI.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,11 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
555555
}
556556
}
557557

558+
private static func getApiEndpoint(apiEndPointOverride: String?, config: IterableConfig) -> String {
559+
let apiEndPoint = config.dataRegion
560+
return apiEndPointOverride ?? apiEndPoint
561+
}
562+
558563
init(apiKey: String,
559564
launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil,
560565
config: IterableConfig = IterableConfig(),
@@ -565,7 +570,7 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
565570
self.apiKey = apiKey
566571
self.launchOptions = launchOptions
567572
self.config = config
568-
apiEndPoint = apiEndPointOverride ?? Endpoint.api
573+
apiEndPoint = InternalIterableAPI.getApiEndpoint(apiEndPointOverride: apiEndPointOverride, config: config)
569574
self.dependencyContainer = dependencyContainer
570575
dateProvider = dependencyContainer.dateProvider
571576
networkSession = dependencyContainer.networkSession

swift-sdk/IterableAPI.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ public final class IterableAPI: NSObject {
104104
launchOptions: [UIApplication.LaunchOptionsKey: Any]?,
105105
config: IterableConfig = IterableConfig()) {
106106
initialize2(apiKey: apiKey,
107-
launchOptions: launchOptions,
108-
config: config)
107+
launchOptions: launchOptions,
108+
config: config,
109+
apiEndPointOverride: config.dataRegion)
109110
}
110111

111112
/// DO NOT USE THIS.

0 commit comments

Comments
 (0)