Skip to content

Commit

Permalink
MOB-4031 fix Client app not running on device and failing test login …
Browse files Browse the repository at this point in the history
…request (#212)

* rename Client target to distinguish from the UI SDK Client, fix test login request for token exchange

* rename target

* update test host for test targets

* fix encoding issue from ios 17

* remove extra protocol
  • Loading branch information
dianakarh authored Apr 16, 2024
1 parent 9483352 commit 49bdd7c
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fastlane/.env

# access keys
Client/Keys.swift
NSDKClient/Keys.swift
Package.resolved
.idea
.bitrise.secrets.yml
Expand Down
87 changes: 56 additions & 31 deletions KarhooSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions KarhooSDK.xcodeproj/xcshareddata/xcschemes/Client.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "09A9B28A2405901900823FB0"
BuildableName = "Client.app"
BlueprintName = "Client"
BuildableName = "NSDKClient.app"
BlueprintName = "NSDKClient"
ReferencedContainer = "container:KarhooSDK.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand Down Expand Up @@ -45,8 +45,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "09A9B28A2405901900823FB0"
BuildableName = "Client.app"
BlueprintName = "Client"
BuildableName = "NSDKClient.app"
BlueprintName = "NSDKClient"
ReferencedContainer = "container:KarhooSDK.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
Expand All @@ -62,8 +62,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "09A9B28A2405901900823FB0"
BuildableName = "Client.app"
BlueprintName = "Client"
BuildableName = "NSDKClient.app"
BlueprintName = "NSDKClient"
ReferencedContainer = "container:KarhooSDK.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
Expand Down
8 changes: 6 additions & 2 deletions KarhooSDK/Network/Common/KarhooCodableModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public protocol KarhooRequestModel: Encodable {
extension KarhooRequestModel {
public func encode() -> Data? {
do {
return try JSONEncoder().encode(self)
let encoder = JSONEncoder()
encoder.outputFormatting = .sortedKeys
return try encoder.encode(self)
} catch let error {
print("----Error Encoding model: \(self) | Reason: \(error.localizedDescription)")
return nil
Expand All @@ -33,7 +35,9 @@ extension KarhooCodableModel {

public func encode() -> Data? {
do {
return try JSONEncoder().encode(self)
let encoder = JSONEncoder()
encoder.outputFormatting = .sortedKeys
return try encoder.encode(self)
} catch let error {
print("----Error Encoding model: \(self) | Reason: \(error.localizedDescription)")
return nil
Expand Down
13 changes: 9 additions & 4 deletions Client/AppDelegate.swift → NSDKClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

struct SDKConfig: KarhooSDKConfiguration {
static var auth: AuthenticationMethod?

func requireSDKAuthentication(callback: @escaping () -> Void) {
callback()
}
Expand All @@ -35,10 +37,13 @@ struct SDKConfig: KarhooSDKConfiguration {
}

func authenticationMethod() -> AuthenticationMethod {
let guestSettings = GuestSettings(identifier: Keys.identifier,
referer: Keys.referer,
organisationId: Keys.organisationId)
return .guest(settings: guestSettings)
guard let auth = SDKConfig.auth else {
let guestSettings = GuestSettings(identifier: Keys.identifier,
referer: Keys.referer,
organisationId: Keys.organisationId)
return .guest(settings: guestSettings)
}
return auth
}
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,14 @@ class AuthRequestsTesterViewController: UIViewController {
}

private func login() {
Karhoo.getAuthService().login(token: "").execute(callback: { [weak self] result in
SDKConfig.auth = .tokenExchange(
settings: TokenExchangeSettings(
clientId: Keys.tokenClientId,
scope: Keys.tokenScope
)
)

Karhoo.getAuthService().login(token: Keys.authToken).execute(callback: { [weak self] result in
if result.isSuccess() {
self?.responseLabel.textColor = .green
let output = """
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 49bdd7c

Please sign in to comment.