Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOB-4031 fix Client app not running on device and failing test login request #212

Merged
merged 5 commits into from
Apr 16, 2024
Merged
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
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
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.