Skip to content

Commit

Permalink
fix(secure-storage): return unfunctional SecureStorageObject if plugi…
Browse files Browse the repository at this point in the history
…n doesn't exist
  • Loading branch information
ihadeed committed Mar 29, 2017
1 parent 612cb96 commit b91757e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/@ionic-native/plugins/secure-storage/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { CordovaInstance, Plugin, CordovaCheck } from '@ionic-native/core';
import { CordovaInstance, Plugin, checkAvailability } from '@ionic-native/core';

declare var cordova: any;

Expand All @@ -8,7 +8,7 @@ declare var cordova: any;
*/
export class SecureStorageObject {

constructor(private _objectInstance: any) {}
constructor(private _objectInstance?: any) {}

/**
* Gets a stored item
Expand Down Expand Up @@ -59,8 +59,6 @@ export class SecureStorageObject {
})
clear(): Promise<any> { return; }



}

/**
Expand Down Expand Up @@ -122,10 +120,13 @@ export class SecureStorage {
* @param store {string}
* @returns {Promise<SecureStorageObject>}
*/
@CordovaCheck()
create(store: string): Promise<SecureStorageObject> {
return new Promise((res, rej) => {
const instance = new cordova.plugins.SecureStorage(() => res(new SecureStorageObject(instance)), rej, store);
if (checkAvailability('cordova.plugins.SecureStorage', null, 'SecureStorage') === true) {
const instance = new cordova.plugins.SecureStorage(() => res(new SecureStorageObject(instance)), rej, store);
} else {
res(new SecureStorageObject());
}
});
}

Expand Down

0 comments on commit b91757e

Please sign in to comment.