cordova-plugin-apple-watch
Advanced tools
+1
-1
| { | ||
| "name": "cordova-plugin-apple-watch", | ||
| "version": "0.8.8", | ||
| "version": "0.9.0", | ||
| "author": "Lee Crossley <leee@hotmail.co.uk> (http://ilee.co.uk/)", | ||
@@ -5,0 +5,0 @@ "description": "Cordova / PhoneGap Plugin for the Apple Watch (WatchKit) to allow in memory and lightweight json object message passing over named queues from a Cordova app to Apple Watch (and vice versa).", |
+1
-1
| <?xml version='1.0' encoding='UTF-8'?> | ||
| <plugin id="cordova-plugin-apple-watch" version="0.8.8" xmlns="http://apache.org/cordova/ns/plugins/1.0"> | ||
| <plugin id="cordova-plugin-apple-watch" version="0.9.0" xmlns="http://apache.org/cordova/ns/plugins/1.0"> | ||
| <name>Apple Watch</name> | ||
@@ -4,0 +4,0 @@ <author>Lee Crossley (http://ilee.co.uk/)</author> |
+10
-0
@@ -225,2 +225,12 @@ ## Apple Watch Plugin for Apache Cordova [](http://badge.fury.io/js/cordova-plugin-apple-watch) | ||
| ### getUserDefaults | ||
| Allows retrieval of user default data. | ||
| ```js | ||
| applewatch.getUserDefaults(successHandler, errorHandler, "myKey", appGroupId); | ||
| ``` | ||
| The app bundleId will be used for identification by default, prefixed by "group." if `appGroupId` is not supplied. | ||
| ## Live demo | ||
@@ -227,0 +237,0 @@ |
@@ -16,2 +16,3 @@ // | ||
| - (void) sendUserDefaults:(CDVInvokedUrlCommand*)command; | ||
| - (void) getUserDefaults:(CDVInvokedUrlCommand*)command; | ||
| - (void) addListener:(CDVInvokedUrlCommand*)command; | ||
@@ -18,0 +19,0 @@ - (void) removeListener:(CDVInvokedUrlCommand*)command; |
+19
-0
@@ -127,2 +127,21 @@ // | ||
| - (void) getUserDefaults:(CDVInvokedUrlCommand*)command | ||
| { | ||
| NSMutableDictionary *args = [command.arguments objectAtIndex:0]; | ||
| NSString *key = [args objectForKey:@"key"]; | ||
| NSString *appGroupId = [args objectForKey:@"appGroupId"]; | ||
| if ([appGroupId length] == 0) | ||
| { | ||
| appGroupId = [NSString stringWithFormat:@"group.%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]]; | ||
| } | ||
| NSUserDefaults *userDefaults = [[NSUserDefaults alloc] initWithSuiteName:appGroupId]; | ||
| NSString *value = [userDefaults stringForKey:key]; | ||
| CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:value]; | ||
| [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; | ||
| } | ||
| - (void) addListener:(CDVInvokedUrlCommand*)command; | ||
@@ -129,0 +148,0 @@ { |
@@ -43,2 +43,10 @@ | ||
| AppleWatch.prototype.getUserDefaults = function (onSuccess, onError, key, appGroupId) { | ||
| var payload = { | ||
| "key": key, | ||
| "appGroupId": appGroupId | ||
| }; | ||
| exec(onSuccess, onError, "AppleWatch", "getUserDefaults", [payload]); | ||
| }; | ||
| AppleWatch.prototype.addListener = function (queueName, onMessage) { | ||
@@ -45,0 +53,0 @@ var wrappedOnMessage = function (message) { |
270623
0.5%271
2.65%246
4.24%