cordova-plugin-apple-watch
cordova-plugin-apple-watch copied to clipboard
Working Sample iOS project
Hi Lee,
thank you for this plugin. However, I'm running into numerous problems trying to make it work.
For examle, I'm having trouble getting the device and watch to communicate. I'm using UserDefault and its simply not getting the values.
On the app side, the messages are being sent successfully, but I get little issues such as applewatch.init's success function not getting run.
On the Watch Ext side, its not receiving the messages. I'm simply checking the NSUserDefaults with the group name but to no avail.
- (void)willActivate { //InterfaceController.m NSUserDefaults * userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.yoyo"]; [userDefaults synchronize]; NSString * myValue = [userDefaults stringForKey:@"myKey"]; if(myValue) { NSLog(@"InterfaceController.m - myValue %@", myValue); [self.displayLabel setText:myValue]; } else { NSLog(@"myValue is null :("); [self.displayLabel setText:@"NULL"]; } }
In Staging folder, Staging/www/js/index.js
I have a button where I run:
function sendMessageButtonClicked() { applewatch.sendUserDefaults(function(){ console.log('index.js - sendUserDefaults sent to watch'); }, function(){ console.log('index.js - sendUserDefaults failed...'); }, { "myKey": "EVIAN" }, "group.com.yoyo"); }
Anyways, can you offer a sample project on how to get everything to work? It may be a great way to resolve all of my issues and be a help to others.
thank you for your time!
I need also a sample project. I also cant get it working, there is no communication between the watch (watchos 2) and app.
+1 Anybody got any solution
Nobody?
For listening messages from iPhone, it works for me to use watchConnectivityListeningWormhole. listenForMessageWithIdentifier
instead of wormhole.listenForMessageWithIdentifier
.
It's quite strange that wormhole.listenForMessageWithIdentifier
only works for initializing the first message, maybe the sample marked in README doesn't conform the Delegate Pattern
as a note to anybody reading this, watchOS2
and on removed the ability to share user defaults across your apps. Essentially, each app owns its own defaults, so if you expect to sendUserDefaults
from the iOS app and have them available from the watch, it simply won't work anymore...
http://stackoverflow.com/questions/36050090/reading-nsuserdefaults-in-watchos-2-i-know-app-groups-doesnt-work#answer-36238647