I’m making a “smart alarm” on watchOs, how to allow a force closed app to still relaunch using ExtendedRuntimeSession?

I’m making a smart alarm for watchOS and I have it mostly functional however if the user was to set the alarm and then force close the app then my alarm fails to play at the scheduled time and instead of the alarm it’s just a notification “Alarm app has been running in the background but failed to play a scheduled alarm. Would you like to disable the app’s ability to run background tasks in future?”. If the app is not force closed then the alarm will play wether the user has the app in the foreground or not.

Am I missing something here? My app has background modes (smart alarm) enabled and I know this functionality is achievable as apps such as “Sleep Cycle” alarm can be force closed on the watch and the alarm still goes off, my ExtendedRuntimeSessionDelegate looks like below:

`import WatchKit

class ExtendedRuntimeSessionDelegate: NSObject, WKExtendedRuntimeSessionDelegate {
var selectedVibration: String = “medium”
var vibrationRepeatDelay: Double = 3.0

let vibrationStrengths: [String: WKHapticType] = [
    "very low": .click,
    "low": .directionUp,
    "medium": .success,
    "high": .start,
    "very high": .notification
]

func extendedRuntimeSessionWillExpire(_ extendedRuntimeSession: WKExtendedRuntimeSession) {
    print("extendedRuntimeSessionWillExpire: Session about to expire")
}

func handle(_ extendedRuntimeSession: WKExtendedRuntimeSession) {
    print("handle: Resuming extended runtime session")
    extendedRuntimeSession.delegate = self
    startVibration(session: extendedRuntimeSession)
}

func extendedRuntimeSessionDidStart(_ extendedRuntimeSession: WKExtendedRuntimeSession) {
    print("extendedRuntimeSessionDidStart: runtime session started")
    startVibration(session: extendedRuntimeSession)

}

func extendedRuntimeSession(_ extendedRuntimeSession: WKExtendedRuntimeSession, didInvalidateWith reason: WKExtendedRuntimeSessionInvalidationReason, error: Error?) {
    print("Session invalidated: (reason)")
    if let error = error {
        print("Error: (error.localizedDescription)")
    }
}

private func startVibration(session: WKExtendedRuntimeSession) {
    print("Start Vibration called")
    let hapticType = vibrationStrengths[selectedVibration] ?? .success
    
    session.notifyUser(hapticType: hapticType) { outHapticType in
        // Repeat the same haptic type based on the vibration repeat delay
        outHapticType.pointee = hapticType
        return self.vibrationRepeatDelay
    }
    
    // Set alarmState to active when the vibration starts
    DispatchQueue.main.async {
        UserDefaults.standard.set(AlarmState.active.rawValue, forKey: "alarmState")
        print("startVibration: Alarm state saved as (AlarmState.active)")
    }
}

func stopVibration(session: WKExtendedRuntimeSession) {
    session.invalidate()
    
    // Update the app's state when the vibration stops
    DispatchQueue.main.async {
        UserDefaults.standard.set(AlarmState.notSet.rawValue, forKey: "alarmState")
        print("stopVibration: Alarm state saved as (AlarmState.notSet)")
    }
}

}
`

I have read through the docs and it would seem “handle()” should be called on the delegate however this is not ever called.

https://developer.apple.com/documentation/watchkit/wkextendedruntimesession/3131068-start

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật