14

After updating to Xcode 7 beta, I receive the following error message: "'openParentApplication(_:reply:)' has been explicitly marked unavailable here", when running the line of code "WKInterfaceController.openParentApplication"

Here is my actual code:

func getData(messageText: String) {
    let infoDictionary = ["message" : messageText]
    WKInterfaceController.openParentApplication(infoDictionary) {
        (replyDictionary, error) -> Void in

        if let castedResponseDictionary = replyDictionary as? [String: String],
            responseMessage = castedResponseDictionary["message"]
        {
            print(responseMessage)
        }
    }
}
Aviv
  • 183
  • 1
  • 6
  • 1
    The API has changed but there is a migration guide: https://developer.apple.com/library/watchos/documentation/General/Conceptual/AppleWatch2TransitionGuide/UpdatetheAppCode.html#//apple_ref/doc/uid/TP40015234-CH6-SW1 – Velizar Hristov Oct 07 '15 at 10:51

1 Answers1

17

+[WKInterfaceController openParentApplication:] is only relevant for WatchKit1 app extensions because with WatchKit1 app extensions, the appex is running on the phone instead of on the watch.

With WatchKit2 app extensions, the appex is running on the watch, so actions such as this are less trivial to accomplish. You probably want to use -[WCSession sendMessageData:replyHandler:errorHandler:] from WatchConnectivity.framework for what you're doing.

Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86
  • 1
    Dude, thanks for the answer but we need a tutorial. Here is one for anyone interested in future --> http://www.kristinathai.com/watchos-2-tutorial-using-sendmessage-for-instantaneous-data-transfer-watch-connectivity-1/ – Sam B Nov 10 '15 at 21:02