EddyVerbruggen / nativescript-secure-storage

:closed_lock_with_key: NativeScript plugin for secure local storage of fi. passwords
MIT License
111 stars 26 forks source link

error while using lib with typescript #2

Closed dlucidone closed 7 years ago

dlucidone commented 7 years ago

i'm getting this error while implementing this - Cannot read property 'hawk' of undefined Any Help!!

EddyVerbruggen commented 7 years ago

Hi,

Can you provide some more information? Which platform, device, version. And which command do you use to run your app? A repo with your app would also help.

dlucidone commented 7 years ago

@EddyVerbruggen I'm developing android app using nativescript-angular. I installed the lib successfully and using your readme I created my ts file

import { Component } from "@angular/core"; import {Observable} from "data/observable"; import {SecureStorage, GetOptions, SetOptions} from "nativescript-secure-storage"; @Component({ selector: "Date", templateUrl: "pages/Date/Date.html", })

export class ConfigureDatePickerComponent extends Observable { public message: string; private secureStorage: SecureStorage;

constructor() { super(); this.secureStorage = new SecureStorage(); }

public doGet() { let that = this; this.secureStorage.get({ key: "foo" }).then((value) => { console.log("Value: " + value); that.set("lastRetrievedValue", value === null ? "(no value set)" : value); }, (err) => { console.log(err); }); }

public doSet() { let that = this; this.secureStorage.set({ key: "foo", value: "I was set at " + new Date() }).then((success) => { console.log("Successfully set a value? " + success); }, (err) => { console.log(err); }); }

}

my package.json dependencies-

"dependencies": { "@angular/common": "2.1.2", "@angular/compiler": "2.1.2", "@angular/core": "2.1.2", "@angular/http": "2.1.2", "@angular/platform-browser": "2.1.2", "@angular/platform-browser-dynamic": "2.1.2", "@angular/platform-server": "2.1.2", "@angular/router": "3.1.2", "nativescript-angular": "1.1.3", "nativescript-calendar": "^1.2.0", "nativescript-secure-storage": "^2.0.0", "reflect-metadata": "0.1.8", "rxjs": "5.0.0-beta.12", "tns-core-modules": "2.4.0"

Anything you need specifically to reproduce the same error please let me know.Thanks

EddyVerbruggen commented 7 years ago

And which command do you use to run your app?

dlucidone commented 7 years ago

on CLI - tns livesync android --watch

EddyVerbruggen commented 7 years ago

Can you try removing and readding the platform and tns run android? If that works go ahead and use livesync again.

dlucidone commented 7 years ago

Yeah i have tried removing android platform and installing again and run the command. still facing the same issue.

EddyVerbruggen commented 7 years ago

OK, let me try this as well as coincidentally I'm building a {N} app with TypeScript (Angular) at the moment and need this plugin myself.

EddyVerbruggen commented 7 years ago

Tried it, works great.

Your problem sounds like #3 (same issue, but for iOS). Can you try tns emulate android / tns run android and then run with livesync again?