I am trying to implement a login-scheme in WatchKit (whether or not having the user type data into his Watch shouldn't be of concern here) which means that after logging in, the user should see a view that doesn't let him go back to the login screen (no <
at the top left corner)
If users get kicked out of their session (e.g. when not paying their subscription) I want the app to go back to the login screen.
Redirecting from the login screen to the main screen works fine using
DispatchQueue.main.async() { [weak self] in
WKInterfaceController.reloadRootControllers(
withNames: ["mainController"], contexts: [values]
)
}
but then when I try to do the same in the main controller using
DispatchQueue.main.async() { [weak self] in
WKInterfaceController.reloadRootControllers(
withNames: ["loginController"], contexts: [message]
)
}
the loginScreen gets displayed BUT the view controller from the main screen stays alive, keeps receiving Notifications from other objects and keeps spawning new loginControllers. I've already tried
self?.pop()
self?.dismiss()
self?.popToRootController()
self?.presentController(withName:
none of which seem to deactivate the mainController. What can I do in this situation?
I do not need ANYTHING from the mainController as I will create a new one after successful login so how can I make sure to destroy the object entirely? I don't want to take care of all the references, listeners, timers, ... in the mainController which is why I am perfectly fine with destroying it.