1

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.

user1242574
  • 1,257
  • 3
  • 12
  • 29
  • Are you sure you’ve done the step to configure the Root.plist correctly? – Jake Apr 15 '18 at 20:21
  • @Jake I have downloaden the included example project from github and did not get it to work. I also created a second new test project via the steps explained in the tutorial but again I’m not able to get it to work. In both cases the ios app crashes when I try to change a setting and the observer does not get triggered. The tutorial is from a few years ago so I think somethings has changed. – user1242574 Apr 16 '18 at 07:21

0 Answers0