I want to create one button in watch and while tapping on watch start one process to my ios app. How can I send the data between 2 devices
-(void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(sayHello:) name: @"sayHelloNotification" object: nil];
}
plus
[[NSNotificationCenter defaultCenter] postNotificationName: @"sayHelloNotification" object: nil];
in my button watch but it doesn't work
You can send data like this..
AFAIK, you can not share data directly, like send some datas between them.
What you can do is write data to same file.
See this blog post:
http://www.atomicbird.com/blog/sharing-with-app-extensions
Better to use updateApplicationContext() to send data from Watch to iPhone if data is redundant && to update data frequently:-
iPhone to receive data
Watch to send data
Demo app
Alternative You can use sendMessage()
iPhone to send data
Watch to receive data
Demo app2
Deprecated openParentApplication:reply: Not supported by watch OS-2
Code of watch in WatchKit executes directly on the iPhone. See Apple documentation.!
If you want to send data to your parent app, use.
Calling this method in your watch app will fire the callback in your AppDelegate
You will have to define your data in the userInfo dictionary thats sent.
Unfortunately, NSNotificationCenter not working between apps. Use MMWormhole to pass messages between WatchKit and iOS.