WatchKit : handleWatchKitExtensionRequest multiple

2019-03-05 08:26发布

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

标签: ios watchkit
1条回答
放荡不羁爱自由
2楼-- · 2019-03-05 08:32

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.

查看更多
登录 后发表回答