Skip to content

Commit b2b15a4

Browse files
authored
Merge pull request #346 from tangem/IOS-5193_add_convenience_method
IOS-5193 Add convenience method
2 parents 151522d + 5a77a2f commit b2b15a4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

TangemSdk/TangemSdk/Common/Extensions/TangemSdk+Combine.swift

+16
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,20 @@ extension TangemSdk {
9797
self.startSession(with: runnable, cardId: cardId, initialMessage: initialMessage, accessCode: accessCode, completion: $0)
9898
}}.eraseToAnyPublisher()
9999
}
100+
101+
/// Combine wrapper for `startSession` method.
102+
/// - Parameters:
103+
/// - runnable: A custom task, adopting `CardSessionRunnable` protocol
104+
/// - filter: Filters card to be read. Optional.
105+
/// - initialMessage: A custom description that shows at the beginning of the NFC session. If nil, default message will be used
106+
/// - accessCode: Access code that will be used for a card session initialization. If nil, Tangem SDK will handle it automatically.
107+
/// - Returns: `AnyPublisher<T.Response, TangemSdkError>`
108+
public func startSessionPublisher<T: CardSessionRunnable>(with runnable: T,
109+
filter: SessionFilter?,
110+
initialMessage: Message? = nil,
111+
accessCode: String? = nil) -> AnyPublisher<T.Response, TangemSdkError> {
112+
return Deferred { Future() {
113+
self.startSession(with: runnable, filter: filter, initialMessage: initialMessage, accessCode: accessCode, completion: $0)
114+
}}.eraseToAnyPublisher()
115+
}
100116
}

0 commit comments

Comments
 (0)