Skip to content

Commit

Permalink
[Mobile Payments] Prevent sleep during Card Reader software updates (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
joshheald authored Sep 25, 2024
2 parents bf7c50c + 0a359f3 commit 194a9d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import Combine
import StripeTerminal
import CoreBluetooth
import class UIKit.UIApplication

/// The adapter wrapping the Stripe Terminal SDK
public final class StripeCardReaderService: NSObject {
Expand Down Expand Up @@ -866,6 +867,7 @@ extension StripeCardReaderService: BluetoothReaderDelegate {
}

public func reader(_ reader: Reader, didStartInstallingUpdate update: ReaderSoftwareUpdate, cancelable: StripeTerminal.Cancelable?) {
UIApplication.shared.isIdleTimerDisabled = true
softwareUpdateSubject.send(.started(cancelable: cancelable.map(StripeCancelable.init(cancelable:))))
}

Expand All @@ -874,6 +876,8 @@ extension StripeCardReaderService: BluetoothReaderDelegate {
}

public func reader(_ reader: Reader, didFinishInstallingUpdate update: ReaderSoftwareUpdate?, error: Error?) {
// Note that this function is called with an error when updates are cancelled, so this is enough to ensure we re-enable sleep.
UIApplication.shared.isIdleTimerDisabled = false
if let error = error {
let underlyingError = Self.logAndDecodeError(error)
softwareUpdateSubject.send(.failed(
Expand Down
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [*] Blaze: Campaign status is now updated immediately after being canceled. [https://github.com/woocommerce/woocommerce-ios/pull/13992]
- [*] Now the keyboard will be open automatically when creating a new Product Category. [https://github.com/woocommerce/woocommerce-ios/pull/14031]
- [internal] Logging for app storage size added in Core Data crash logs [https://github.com/woocommerce/woocommerce-ios/pull/14008]
- [*] Payments: Prevent phone from sleeping during card reader updates [https://github.com/woocommerce/woocommerce-ios/pull/14021]
- [internal] Fixed concurrency issue with Blaze local notification scheduler. [https://github.com/woocommerce/woocommerce-ios/pull/14012]

20.5
Expand Down

0 comments on commit 194a9d1

Please sign in to comment.