title: Ionic secure storage - Ask the user to set a lock screen
body: <p>I'm trying to initialize the secure storage plugin. When this fails it means the user does not have a secure lockscreen set. Using the github page i'm trying to recreate the sample provided: </p>
  
  <pre><code>var ss;
  var _init = function () {
      ss = new cordova.plugins.SecureStorage(
          function () {
              console.log('OK');
          },
          function () {
              navigator.notification.alert(
                  'Please enable the screen lock on your device. This app cannot operate securely without it.',
                  function () {
                      ss.secureDevice(
                          function () {
                              _init();
                          },
                          function () {
                              _init();
                          }
                      );
                  },
                  'Screen lock is disabled'
              );
          },
          'my_app');
  };
  _init();
  </code></pre>
  
  <p>This is my attempt: </p>
  
  <pre><code>private createSecureStorage() {
      this.secureStorageAPI.create(this.storeName).then( 
          (storage: SecureStorageObject) =&gt; {
              this.secureStorage = storage;
      }).catch( 
          (error) =&gt; {
              this.dialogs.alert( 'Please enable the screen lock on your device. This app cannot operate securely without it.').then( 
                  () =&gt; {
                  // Alert Dismissed, should open the secure lockscreen settings here
                    this.secureStorage.secureDevice().then( 
                        () =&gt; {
                            // Try again
                            this.createSecureStorage();
                        }
                    ).catch( () =&gt; { 
                      // Try again
                      this.createSecureStorage();
                    })
                 } )
        } );
    }
  </code></pre>
  
  <p>The problem i'm having is that when the secureStorageApi.create call fails, secureStorage will be undefined so I can't use it to call call secureDevice(). </p>
  
  <p>Any help would be much appreciated. </p>