Skip to content

Commit

Permalink
Merge pull request #7 from UseAlloy/feature/sc-118311/issues-with-pro…
Browse files Browse the repository at this point in the history
…duction-false-sandbox-in-ios

Feature/sc-118311/issues-with-production-false-sandbox-in-ios
  • Loading branch information
mrestuccia authored May 8, 2023
2 parents 97b5410 + ccb4da0 commit 160f1a4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Example/AlloyCodelessLiteiOSDemo/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct ContentView: View {
let entities = EntityData(entities: [entityPerson, entityPerson2], additionalEntities: false)
// *** this key is part of a working example ***
// You should obtain your journey token from the journey's list
let journeySettings = JourneySettings(journeyToken: "J-UMEhLDP3p759425pz1uP", entities: entities)
let journeySettings = JourneySettings(journeyToken: "J-UMEhLDP3p759425pz1uP", entities: entities, production: false)
let journeyResult = try await AlloyCodelessLiteiOS.shared.startJourney(journeySettings: journeySettings, onFinish: { _ in
showResultJourney.toggle()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class AlloySettings {
// Configure SDK with production environment (default is false)
public var production = false

// Configure SDK for make tests in environment (default is false)
public var realProduction = false
// Configure SDK for make tests in environment (default is true)
public var realProduction = true

public var codelessFinalValidation = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ public class JourneySettings {

public var journeyToken: String = ""
public var entities: EntityData = EntityData(entities: [], additionalEntities: false)

public var production: Bool = false;
init() {}

public init(journeyToken: String, entities: EntityData) {
public init(journeyToken: String, entities: EntityData, production: Bool) {
self.journeyToken = journeyToken
self.entities = entities
self.production = production
}

public func getFirstNameEntity(withIndex i: Int) -> String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
headers.add(HTTPHeader.authorization(bearerToken: TokenHolder.tokens.accessToken))

switch self {
case .createJourney:
case .createJourney(_, let journeySettings):
headers.add(name:"alloy-journey-override-sync", value: "true")
headers.add(name:"alloy-sandbox", value: "\(!journeySettings.production)")
default:
break
}

return headers

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ internal struct PluginURLBuilder {
var apiKey: String
var journeyToken: String
var applicationToken: String
var production: Bool

init(apiKey: String, journeyToken: String, applicationToken: String) {
init(apiKey: String, journeyToken: String, applicationToken: String, production: Bool) {
self.apiKey = apiKey
self.journeyToken = journeyToken
self.applicationToken = applicationToken
self.production = production && false
}

public func getPluginURL() -> String {
baseUrl + "journeyApplicationToken=\(applicationToken)&journeyToken=\(journeyToken)&key=\(apiKey)"
baseUrl + "journeyApplicationToken=\(applicationToken)&journeyToken=\(journeyToken)&key=\(apiKey)&production=\(production)"
}
}
6 changes: 4 additions & 2 deletions Sources/alloy-codeless-lite-ios/Services/JourneyService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ internal struct JourneyService {
let urlPlugin = PluginURLBuilder(
apiKey: AlloyCodelessLiteiOS.shared.alloySettings.apiKey ?? "",
journeyToken: journeySettings.journeyToken,
applicationToken: TokenHolder.tokens.journeyApplicationToken
applicationToken: TokenHolder.tokens.journeyApplicationToken,
production: journeySettings.production
)
UIUtils.presentView(viewController: WebViewController(url: urlPlugin.getPluginURL(), onFinish: onFinish), presentationStyle: .overFullScreen)
}
Expand Down Expand Up @@ -50,7 +51,8 @@ internal struct JourneyService {
let urlPlugin = PluginURLBuilder(
apiKey: AlloyCodelessLiteiOS.shared.alloySettings.apiKey ?? "",
journeyToken: journeySettings.journeyToken,
applicationToken: TokenHolder.tokens.journeyApplicationToken
applicationToken: TokenHolder.tokens.journeyApplicationToken,
production: journeySettings.production
)
await UIUtils.presentView(viewController: WebViewController(url: urlPlugin.getPluginURL(), onFinish: onFinish), presentationStyle: .overFullScreen)
}
Expand Down

0 comments on commit 160f1a4

Please sign in to comment.