So I want to use the following cordova plugin within my Ionic 2 app: https://github.com/Crypho/cordova-plugin-secure-storage
I am aware Ionic does have it’s own version of SecureStorage but it doesn’t have all of the features I need whereas the cordova one I linked to above does. I am told there is a way to get a cordova plugin working within my app without official Ionic support but the way I have tried isn’t baring any results for what I can see:
import { Component, ViewChild } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { TranslateService } from '@ngx-translate/core';
import { Push, PushToken } from '@ionic/cloud-angular';
import { Storage } from "@ionic/storage";
import { GoogleAnalytics } from '@ionic-native/google-analytics';
import { Vibration } from '@ionic-native/vibration';
import { Deploy } from '@ionic/cloud-angular';
import { AlertController } from 'ionic-angular';
declare var cordova: any;
import { HomePage } from '../pages/login/login';
import { EnterSocialsecurityPage } from '../pages/enter-social-security/enter-social-security';
import { VerifypincodePage } from '../pages/verify-pincode/verify-pincode';
import { CreatepincodePage } from '../pages/create-pincode/create-pincode';
@Component({
template: '<ion-nav #myNav [root]="rootPage"></ion-nav>'
})
export class MyApp {
@ViewChild('myNav') navCtrl
rootPage:any = HomePage;
lang = "en";
translation = "";
constructor(platform: Platform, private statusBar: StatusBar, splashScreen: SplashScreen, translate: TranslateService, public push: Push, public storage: Storage, private ga: GoogleAnalytics, private vibration: Vibration, public deploy: Deploy, public alertCtrl: AlertController) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.backgroundColorByHexString('#343538');
statusBar.styleLightContent();
splashScreen.hide();
// Device Security
new cordova.plugins.SecureStorage(
function () { console.log('Success')},
function (error) { console.log('Error ' + error); },
'my_app');
});
...
}
}
Can anyone tell me a better way or why my way is not working? Thanks.