I’m within the center levels of creating an app that considered one of its function is fall and in addition crash detection, exterior options greater than the opposite comparable apps. I might clearly want the app to run within the background on a regular basis analyze the acceleration and another parameters along with fetching location coordinates.
I’m questioning how I can obtain this with out getting issues with Apple Retailer insurance policies or the truth that iOS and watchOS each in all probability would terminate my app in some unspecified time in the future I’ve additionally optimized the CPU and reminiscence utilization to the minimal stage.
Additionally do you assume I’ve to overlook about my challenge not being definitely worth the effort and time?
Right here is instance is an prolonged session that may begin in watchOS:
import WatchKit
class MindfulnessController: WKInterfaceController, WKExtendedRuntimeSessionDelegate {
var session: WKExtendedRuntimeSession?
override func willActivate() {
tremendous.willActivate()
startMindfulnessSession()
}
func startMindfulnessSession() {
session = WKExtendedRuntimeSession()
session?.delegate = self
session?.begin()
// Start mindfulness exercise, e.g., play calming sounds or information respiratory workouts
}
func extendedRuntimeSessionDidStart(_ session: WKExtendedRuntimeSession) {
// Session began efficiently
}
func extendedRuntimeSessionWillExpire(_ session: WKExtendedRuntimeSession) {
// Session is about to run out; wrap up the mindfulness exercise
}
func extendedRuntimeSession(_ session: WKExtendedRuntimeSession, didInvalidateWith purpose: WKExtendedRuntimeSessionInvalidationReason, error: Error?) {
// Deal with session invalidation
}
}