1

I am doing a sample project in which i like to send data from iphone to WatchKit. I have no idea of how to do this. Any help will be appreciated. Thanks in advance

1 Answer 1

5

Add this method in the AppDelegate:

func application(application: UIApplication!,
handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]!,
   reply: (([NSObject : AnyObject]!) -> Void)!)
{
   //define your dictionary
   reply(yourDict)
}

Add this anywhere in the Apple Watch Extension:

var dict = ["test" : 4] //your dictionary/request to sent to the iPhone
if !WKInterfaceController.openParentApplication(dict, reply: { (reply,error) -> Void in
    println("\(reply)") //your reply data as Dictionary
}) {
    println("ERROR")
}

The first function will trigger with WKInterfaceController.openParentApplication and will reply the dictionary in the reply parameter.

Developer forum: https://devforums.apple.com/message/1082689#1082689

Sign up to request clarification or add additional context in comments.

3 Comments

what i trying to do is i am getting data from server, store it in coredata in phoneside then fetch from coredata and send it watchkit.can i done this with above code?
AFAIK, this to send data from Watch to iPhone, not from iPhone to Watch
This sends data bothways, just put your data in the reply Dictionary

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.