Search code examples
ioswatchkit

WatchKit : handleWatchKitExtensionRequest multiple instances


So I have a parent app that logs in to a server, creates a user etc. I then use handleWatchKitExtensionRequest from the WatchApp to access the parent app but everything is null.

My question is, does handleWatchKitExtensionRequest get run in a different instance to the parent app? I read somewhere it does but I just need this confirmed.

Thanks


Solution

  • If handleWatchKitExtensionRequest returns nothing it means that the passed reply is never called. This is most probably due to application.didFinishLaunchingWithOptions runs into an error when the app is launched in background mode.

    I had a similar issue with my app where I did some initializations on the app's navigationController. It turned out that the navigationController is not accessible when the app is launched in background mode.

    I would suggest to completely comment out the code in didFinishLaunchingWithOptions and see if handleWatchKitExtensionRequest calls its reply. If so, uncomment the code in didFinishWithLaunchingWithOptions step by step to detect the faulty code.

    This may be really hard to track down because one cannot attach the debugger to the iPhone app at this time of launching.

    Another pitfall: The function signature of handleWatchKitExtensionRequest has changed in Swift 1.2 without giving any compiler errors. It took me hours to figure that out.