Reader Update Publisher

readerUpdatePublisher

The readerUpdatePublisher is a PassthroughSubject exposed by the Tyro SDK to communicate information about the state of the reader on the device. It acts as a UI delegate that signals changes or updates to the reader.

Firmware updates on the reader can occur at any time and take anywhere between 1-2 minutes to finish so it is important to notify the app user of the status of the reader so they are not left waiting.

Ensure your app subscribes to readerUpdatePublisher early in the application lifecycle to capture all events, especially during the reader initialisation.

Copy
Copied
public final public var readerUpdatePublisher: PassthroughSubject<ProximityReaderEvent, Never>

Events

Reader update eventDescription
updateStartedReader update event has started
updateInProgress(progress: Int)Progress of the reader update event. progress is an integer from 0-100 indicatoring the progress of the update
updateCompletedReader update has completed
updateFailed(error: any Error)There was an error with the reader update. The inner error object contains more details.

Example

Copy
Copied
import Combine

class ViewModel: ObservableObject {
  var tyroTapToPaySdk: TyroTapToPay
  private var cancellables = Set<AnyCancellable>()

  init() {
    tyroTapToPaySdk.readerUpdatePublisher
      .sink { event in
        switch event {
        case .updateStarted:
          print("Reader update started")
        case .updateInProgress(let progress):
          print("Updating reader: \(progress)%")
        case .updateCompleted:
          print("Reader update complete")
        case .updateFailed(let error):
          print("ERROR: Reader update failed: \(error)")
          // retry the update
        @unknown default:
          print("Unknown reader update event: \(event)")
        }
      }
      .store(in: &cancellables)
  }
}
Copyright © Tyro Payments 2019-2024. All right reserved.