Ionic and KeychainPlugin problems


#1

Hey

Anyone out there who has used the plugin called KeychainPlugin (https://github.com/shazron/KeychainPlugin) in their Ionic-app with success?

I tried adding the plugin to my Ionic-app yesterday but I couldn’t get it to work. The documentation of this plugin is quite sparse. I’ve added lots of plugins from the ngcordova.com site before with success, but this one… just won’t get it to work.

According to ngcordova.com the plugin should be added and accessed in the following way:

module.controller(‘MyCtrl’, function($scope, $cordovaKeychain) {

$scope.getValueFromKey = function(key) {
$cordovaKeychain.getForKey(key, servicename).then(function(value) {
console.log(value);
}, function (err) {
console.error(err);
});
};

});

But as soon as I add $cordovaKeychain to the module declaration (first row) the the app will halt running in Xcode.

I’ve tried excluding the $cordovaKeychain from the module declaration, and just go with the example code for the keychainplugin on github and doing:

//This works
var kc = new Keychain();

//But this doesn’t work, when I add this row, the app will halt in Xcode
kc.getForKey(win, fail, “some_key”, “some_servicename”);

Any clues anyone?


#2

No one out there who has used the keychain-plugin?


#3

I tried to use it, but it is not working. Wasted a whole day debugging it.
I followed the below guideline:

http://ngcordova.com/docs/#Keychain

If anyone has a Keychain working example for ionic, please post it.

I could get other plugin (e.g. ngGeolocation) working but not the Keychain.


#4

You dont even need to run it on iOS to prove it does not work.
Just do ionic serve, and the browser will complain Keychain undefined (in the ng-cordova.js).


#5

Stumbled upon the same issue. Here is a fix https://github.com/driftyco/ng-cordova/pull/637.


#6

Thanks for posting the fix. I encountered the same issues and the fix worked.


#7

Hi Sir,
May I know how you fixed the problem? Could you share? Appreciate


#8

Still its not working , i tried to run app on browser as well on device it shows keychain not defined. Can you guys put a working example for your fix?