When a user changes settings in the Watch App on his iPhone I want my app interface on the users watch to be updated accordingly.
I followed all the instructions in the following tutorial and created a shared watch-setting.bundle and added a observer (I updated the code to swift 4).
class InterfaceController: WKInterfaceController {
override func awake(withContext context: Any?) {
super.awake(withContext: context)
// Configure interface objects here...
NotificationCenter.default.addObserver(self, selector: #selector(InterfaceController.changeFunc), name: UserDefaults.didChangeNotification, object: nil)
}
fun changeFunc() {
print("setting changed!")
}
}
When I run the app the observer is triggered and the line "setting changed!" is printed in the log screen.
But when I try to change a setting in the Watch app on my iPhone the observer does not trigger.