stripe-terminal-ios icon indicating copy to clipboard operation
stripe-terminal-ios copied to clipboard

Terminal.shared.disconnectReader doesn't work when app is about to go in the background or terminate

Open harsh7703 opened this issue 1 year ago • 6 comments

Summary

I want to disconnect the reader when the app is supposed to go in the background state or let's say it is about to terminate. This same code works when the app is foreground but does not work when the app is about to switch its state.

Code to reproduce


NotificationCenter.default.addObserver(self, selector: #selector(appWillEnterBackground), name: UIApplication.willResignActiveNotification, object: nil)

func appWillEnterBackground() {
      Terminal.shared.disconnectReader { error in
                if let error = error {
                    print("Disconnect failed: \(error)")
                } else {
                    print("--------------- Disconnected --------------")
                }
            }
}

iOS version

18.0.1

Installation method

Cocoapods

SDK version

3.9.1

Other information

harsh7703 avatar Oct 27 '24 08:10 harsh7703