I am trying to build a timing app for the watch that vibrates every minute just as a way for the user to keep track of time. I have the timer correctly working and vibrating, but once the screen on the watch goes off, it no longer vibrates. Once I wake the screen back up, it goes back to normal.
Right now to send the vibration I am using this:
WKInterfaceDevice.currentDevice().playHaptic(.Stop)
I know this might be some sort of design implementation to save battery life, but obviously the point of my app is to keep the track of time even when the screen is off. Is something like this possible?
To do this, press the Digital Crown to see the Home screen, then tap the Settings button . Tap Display & Brightness. Scroll down, then tap Always On. Tap Always On to turn on or turn off the feature.
Apple Watch continues to display your app's user interface as long as it's either the frontmost app or running a background session. To preserve battery life, the system updates the user interface at a much lower frequency than when running in the foreground. It also dims the watch.
To keep a watchOS app running after the screen turns off it is now possible to use the new WKExtendedRuntimeSession commands offered in watchOS 6.
Inside your WatchKit Extension ExtensionDelegate file create an extended runtime session with the following command.
let session = WKExtendedRuntimeSession()
Within this delegate file create an applicationDidBecomeActive() function which watchOS will call when your app becomes active. Inside this function start the ExtendedRuntime Session with the following commands.
session.delegate = self // self as session handler
session.start() // start WKExtendedRuntimeSession
An extended runtime session must be started when the app is in the active state.
Note you also need to enable Background Modes within the WatchKit Extension target. Select one of the Session Types that most closely fits the type of app you are creating.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With