Scene Changes

tapToPaySdk.didChange(scenePhase: ScenePhase) async

Notifies the SDK that the scene has changed in the application. Readers can disconnect if the application is sent to the background. Therefore, it is necessary to notify the SDK about the scene changing to handle the disconnection and re-connection of the reader.

This modifier should be added to the main ContentView of the application.

Copy
Copied
public func didChange(scenePhase: ScenePhase) async

Parameters

scenePhase
required
ScenePhase

An indication of a scene's operational state.

Example Usage

Copy
Copied
//
//  ContentView.swift
//

import Foundation
import SwiftUI

struct ContentView: View {
  @Environment(\.scenePhase) private var scenePhase
  private let tapToPaySdk: TyroTapToPay

  var body: some View {
    VStack {
      Text("App main content view")
    }
    .onChange(of: scenePhase) { (_, newValue) in
      Task.detached {
        await tapToPaySdk.didChange(scenePhase: newValue)
      }
    }
  }
}
Copyright © Tyro Payments 2019-2024. All right reserved.