Search code examples
iosxcodewatchkitapple-watch

Call openParentApplication the second time without calling reply for the first one


I call openParentApplication method in WKInterfaceController and in iOS waiting response from server. Then I want to cancel the operation for waiting response in iOS using openParentApplication again.

But the first call didn't call reply so the second I call openParentApplication it not fire the handleWatchKitExtensionRequest. Need to wait the timeout from the first call and then the second call will fired in handleWatchKitExtensionRequest.

Is there any method to cancel the first call to without wait the reply?


Solution

  • The documentation confirms your problem:

    If you call this method multiple times in quick succession, your calls are serialized so that each subsequent call is delayed until the response from the previous call is received.

    To cancel your first call, you could change a value in a shared NSUserDefaults object and check for the change in the parent applications. If changed, the first call is cancelled.

    Another option is to use Darwin notifications or MMWormhole to send a message from WatchKit to your parent application.