In the case where an application requires authentication to view content (say, a social media app, a banking app, or any app with a login) - what's a good way to handle changes to that authentication state while the WatchKit app is open?
Scenario A: Sign In from iOS app while WatchKit is running. Let's say you launch the WatchKit app, and you're not signed in. The WatchKit app would show you some kind of "please sign in" state, and prompt you to open the iOS app to sign in. When that sign in occurs, how do I notify the WatchKit interface controller to refresh its contents?
Scenario B: Sign out from iOS app while WatchKit is running. let's say you launch the WatchKit app, and you ARE signed in. Then you open the iOS app and sign out - how should I notify the WatchKit app that you've now signed out, and that it should display that "please sign in" state again?
Do I use a timer that constantly checks the auth state? Is there a notification system that I can use?
For both scenarios, you can send a Darwin notification from the iOS app. Have the WatchKit extension register for one notification string that indicates sign in, and one sign out, and you're sorted.
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