can i recognize the watchos application when active?

I solved this issue by using WKExtensionDelegate and my own notifications.

struct ExtensionApp: App {
    @WKExtensionDelegateAdaptor(ExtensionDelegate.self) var appDelegate

    @SceneBuilder var body: some Scene {
        WindowGroup {
            NavigationView {
import WatchKit

final class ExtensionDelegate: NSObject, ObservableObject, WKExtensionDelegate {
    func applicationDidFinishLaunching() {
        NSLog("App launched")

    func applicationDidBecomeActive() {
        NSLog("App activated") .appActivated, object: nil)

    func applicationDidEnterBackground() {
        NSLog("App deactivated") .appDeactivated, object: nil)
import Foundation

extension Notification.Name {
    static let appActivated = Notification.Name("app.activated")
    static let appDeactivated = Notification.Name("app.deactivated")

then I was able to listen to these events in my SwiftUI view:

.onReceive(NotificationCenter.default.publisher(for: .appActivated)) { _ in
.onReceive(NotificationCenter.default.publisher(for: .appDeactivated)) { _ in

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top