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

Twint crash fix #1916

Merged
merged 18 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
18 changes: 17 additions & 1 deletion AdyenActions/AdyenActionComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,35 @@ public final class AdyenActionComponent: ActionComponent, ActionHandlingComponen
public struct Twint {

/// The callback app scheme invoked once the Twint app is done with the payment
///
/// - Important: This value is required to only provide the scheme,
/// without a host/path/.... (e.g. "my-app", not a url "my-app://...")
public var callbackAppScheme: String

/// The issuer number of the highest scheme you listed under `LSApplicationQueriesSchemes`.
/// E.g. pass 39, if you listed all schemes from "twint-issuer1" up to and including "twint-issuer39". The value is clamped between 0 and 39.
///
/// - Important: All apps above "twint-issuer39" will always be returned if one of these apps is installed. For this to work, `LSApplicationQueriesSchemes` must include "twint-extended".
/// If you configure any `maxIssuerNumber` below 39, the result will always contain all apps above `maxIssuerNumber` up to and including 39, even if none of them are installed.
/// Additionally, if the fetch fails and the cache is empty, none of these apps will be found when probing.
public var maxIssuerNumber: Int

/// Initializes a new instance
///
/// - Parameter callbackAppScheme: The callback app scheme invoked once the Twint app is done with the payment
///
/// - Important: The value of ``callbackAppScheme`` is required to only provide the scheme,
/// without a host/path/... (e.g. "my-app", not a url "my-app://...")
public init(callbackAppScheme: String) {
public init(
callbackAppScheme: String,
maxIssuerNumber: Int = .max
) {
if !Self.isCallbackSchemeValid(callbackAppScheme) {
AdyenAssertion.assertionFailure(message: "Format of provided callbackAppScheme '\(callbackAppScheme)' is incorrect.")
}

self.callbackAppScheme = callbackAppScheme
self.maxIssuerNumber = maxIssuerNumber
}

/// Validating whether or not the provided `callbackAppScheme` only contains a scheme
Expand Down Expand Up @@ -265,6 +280,7 @@ public final class AdyenActionComponent: ActionComponent, ActionHandlingComponen
configuration: .init(
style: configuration.style.awaitComponentStyle,
callbackAppScheme: twintConfiguration.callbackAppScheme,
maxIssuerNumber: twintConfiguration.maxIssuerNumber,
localizationParameters: configuration.localizationParameters
)
)
Expand Down
5 changes: 3 additions & 2 deletions AdyenActions/Components/SDK/Twint+Injectable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import Foundation
completion: @escaping ([TWAppConfiguration]) -> Void
) {
Twint.fetchInstalledAppConfigurations(withMaxIssuerNumber: maxIssuerNumber) { configurations in
completion(configurations ?? [])
let configurationObjects = (configurations as [NSObject]?) ?? []
completion(configurationObjects.compactMap { $0 as? TWAppConfiguration })
}
}

Expand Down Expand Up @@ -55,7 +56,7 @@ import Foundation
cancelHandler: @escaping () -> Void
) -> UIAlertController? {
Twint.controller(
for: installedAppConfigurations.map { $0 },
for: installedAppConfigurations,
selectedConfigurationHandler: { selectionHandler($0) },
cancelHandler: { cancelHandler() }
)
Expand Down
Loading