WatchKit : handleWatchKitExtensionRequest multiple instances

前端 未结 1 1528
我寻月下人不归
我寻月下人不归 2021-01-25 23:45

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

相关标签:
1条回答
  • 2021-01-26 00:21

    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.

    0 讨论(0)
提交回复
热议问题