Telerik-Verified-Plugins / AppleWatch

Cordova AppleWatch plugin, build the Watch UI with JavaScript!
MIT License
123 stars 36 forks source link

Doesn't work after app deactivation #4

Closed bfischer1121 closed 9 years ago

bfischer1121 commented 9 years ago

I'm having problems updating the watch after hiding the app and then showing it again.

Steps to reproduce:

Open the Apple Watch app and keep it active (rotating the crown seems to do this well). One handed, open up safari's remote debug and update the main page a few times: applewatch.loadAppMain({ label: { value: 'a' } }); applewatch.loadAppMain({ label: { value: 'b' } }); ...

That should work. But if you deactivate the app by pressing the crown, open it again, and try the same thing it has no effect.

Stepping through the code, mmwormhole didn't have any listeners. I think ParentInterfaceController.m#didDeactivate is removing them and they're never re-attached.

I'm not a native dev so maybe I'm off, but I think that's the issue :)

bfischer1121 commented 9 years ago

So re-attaching on willActivate fixes the issue, but I'm not sure if that's the proper place to put it and whether the same handler ends up attached twice in the lifecycle:

[Update: Yep, it does]

EddyVerbruggen commented 9 years ago

Fixed by #5