Bladeren bron

Fixes #7 - Update plugin.xml for Cordova 3.0.0

Shazron Abdullah 12 jaren geleden
bovenliggende
commit
0a835d738e
3 gewijzigde bestanden met toevoegingen van 38 en 63 verwijderingen
  1. 7 21
      README.md
  2. 6 15
      plugin.xml
  3. 25 27
      www/keychain.js

+ 7 - 21
README.md

@@ -4,29 +4,15 @@ created by Shazron Abdullah
 
 [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html) except for the SFHFKeychainUtils code that is under **src/ios/SFHFKeychainUtils**
 
-Follows the [Cordova Plugin spec](https://github.com/apache/cordova-plugman/blob/master/plugin_spec.md), so that it works with [Plugman](https://github.com/apache/cordova-plugman), or you can install it manually below.
+Follows the [Cordova Plugin spec](http://cordova.apache.org/docs/en/3.0.0/plugin_ref_spec.md), so that it works with [Plugman](https://github.com/apache/cordova-plugman), or you can install it manually below.
  
-1. Add the SFHFKeychainUtils files **(SFHFKeychainUtils.m, and SFHFKeychainUtils.h)** in Xcode (add as a group)
-2. Add the plugin files **(CDVKeychain.h, CDVKeychain.m)** in Xcode (add as a group)
-3. Add **keychain.js** to your **www** folder, and reference it in a script tag, after your cordova.js
-4. 
-	a. For __Cordova.plist__, under the **'Plugins'** key, add a new row: key is **"Keychain"** and the value is **"CDVKeychain"**
-	
-	b. For __config.xml__, under the **<plugins>** tag, add this (deprecated, 2.7.0 and below):
-	     
-	     <plugin name="Keychain" value="CDVKeychain" />
-	
-	c. For __config.xml__, add a new **&lt;feature&gt;** tag (2.8.0 and up):
+Manually importing the plugin is not supported anymore, please use [Plugman](http://npmjs.org/plugman)     or the [Cordova CLI tool](http://npmjs.org/cordova)    
 
-         <feature name="Keychain">
-            <param name="ios-package" value="CDVKeychain" />
-         </feature>
-	
-5. Add the framework **"Security.framework"**
-    
-The plugin's JavaScript functions are called after getting the plugin object thus:
+The "Keychain" object definition is installed globally. 
+
+The plugin's JavaScript functions are called after creating the plugin object thus:
  
-        var kc = cordova.require("cordova/plugin/keychain");
+        var kc = new Keychain();
         kc.getForKey(win, fail, "some_key", "some_servicename");
         
 **Important:**
@@ -48,7 +34,7 @@ The plugin's JavaScript functions are called after getting the plugin object thu
 See the **example** folder for example usage.
 
         // Get a reference to the plugin first
-        var kc = cordova.require("cordova/plugin/keychain");
+        var kc = new Keychain();
 
         /*
          Retrieves a value for a key and servicename.

+ 6 - 15
plugin.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
-    id="com.shazron.cordova.keychainutil"
+    id="com.shazron.cordova.plugin.keychainutil"
     version="1.0.0">
 
     <name>iOS KeyChain</name>
@@ -11,35 +11,26 @@
 	
     <asset src="www/keychain.js" target="plugins/keychain.js" />
 
+	<js-module src="www/keychain.js" name="Keychain">
+    	<clobbers target="window.Keychain" />
+	</js-module>
+	
     <!-- ios -->
     <platform name="ios">
-        <!-- Only for Cordova 2.2.0 -->
-        <plugins-plist key="Keychain" string="CDVKeychain" />
-               
         <!-- feature tag in config.xml -->
         <config-file target="config.xml" parent="/widget">
           <feature name="Keychain">
             <param name="ios-package" value="CDVKeychain"/>
           </feature>
         </config-file>
-
-        <!-- deprecated plugins tag in config.xml -->
-        <config-file target="config.xml" parent="/*/plugins">
-            <plugin name="Keychain" value="CDVKeychain"/>
-        </config-file>
         
         <header-file src="src/ios/CDVKeychain.h" />
         <header-file src="src/ios/SFHFKeychainUtils/SFHFKeychainUtils.h"/>
         
         <source-file src="src/ios/CDVKeychain.m"/>
-        <source-file src="src/ios/SFHFKeychainUtils/SFHFKeychainUtils.m" />
+        <source-file src="src/ios/SFHFKeychainUtils/SFHFKeychainUtils.m" compiler-flags="-fno-objc-arc" />
         
         <framework src="Security.framework" />
         
-        <info>
-Add this script tag to your index.html:
-    &lt;script src="plugins/keychain.js"&gt;&lt;/script&gt;
-	    </info>
-
     </platform>
 </plugin>

+ 25 - 27
www/keychain.js

@@ -16,30 +16,28 @@
  specific language governing permissions and limitations
  under the License.
  */
- 
- cordova.define("cordova/plugin/keychain", function(require, exports, module) {
- 	var exec = require('cordova/exec');
-
-	var Keychain = function() {
-	    this.serviceName = "Keychain";
-	};
-
-    Keychain.prototype.getForKey = function(successCallback, failureCallback, key, servicename)
-    {
-        exec(successCallback, failureCallback, this.serviceName, "getForKey", [key, servicename]);
-    }
-    
-    Keychain.prototype.setForKey = function(successCallback, failureCallback, key, servicename, value)
-    {
-        exec(successCallback, failureCallback, this.serviceName, "setForKey", [key, servicename, value]);
-    }
-    
-    Keychain.prototype.removeForKey = function(successCallback, failureCallback, key, servicename)
-    {
-        exec(successCallback, failureCallback, this.serviceName, "removeForKey", [key, servicename]);
-    }
-
- 	var keychain = new Keychain();
- 	module.exports = keychain;
-
- });
+
+// This is installed as a <js-module /> so it doesn't have a cordova.define wrapper
+
+var exec = require('cordova/exec');
+
+var Keychain = function() {
+	this.serviceName = "Keychain";
+};
+
+Keychain.prototype.getForKey = function(successCallback, failureCallback, key, servicename)
+{
+	exec(successCallback, failureCallback, this.serviceName, "getForKey", [key, servicename]);
+}
+
+Keychain.prototype.setForKey = function(successCallback, failureCallback, key, servicename, value)
+{
+	exec(successCallback, failureCallback, this.serviceName, "setForKey", [key, servicename, value]);
+}
+
+Keychain.prototype.removeForKey = function(successCallback, failureCallback, key, servicename)
+{
+	exec(successCallback, failureCallback, this.serviceName, "removeForKey", [key, servicename]);
+}
+
+module.exports = Keychain;