-1

In watchos we can back to clock(homescreen) by two way.

click dial cover screen with hand

My app record audio with avaudioengine. But when i try to back to clock by two way written above. App didn't stay in background, but appear in screen with inactive state. This happens only while recording, while not recording app acts normally.

For example, built-in voice recording app excuted in background when we go back to clock by clicking dial. And the app goes inactive when covering screen with hand.

How can i make my app stay in background when dial clicked like built-in recording app. help me please!!

i tried set info.plist background mode but it doesn't works.

1 Answers1

0

you can implement an action when the screen is covered with a hand using the 'WKInterfaceDevice' class. The 'WKInterfaceDevice' class provides the 'isScreenInWakeState' property, which you can use to check whether the screen is covered with a hand.

class ExtensionDelegate: NSObject, WKExtensionDelegate {
func applicationDidBecomeActive() {
    let device = WKInterfaceDevice.current()
    if device.isScreenInWakeState {
        // Perform your action here
        WKInterfaceDevice.current().play(.success)
    }
  }
}
Alamgir
  • 21
  • 5