Search code examples
watchkitapplication-state

Listen for application will enter foreground on WatchKit?


On iOS, I have several ways to know when the user launched my app from the home screen when the app was backgrounded:

Is there an equivalent in WatchKit? If not, are there any robust alternatives?


Solution

  • The closest you'll find with a WatchKit extension is this set of notifications that were introduced in iOS 8.2:

    NSExtensionHostWillEnterForegroundNotification
    NSExtensionHostDidEnterBackgroundNotification
    NSExtensionHostWillResignActiveNotification
    NSExtensionHostDidBecomeActiveNotification
    

    You can read more about these notifications in the NSExtensionContext documentation.