Q:

How can be saved login detail in Native Script

When I sign in, my login should be saved, I don't want to enter the userName Password each and every login time.
below my code :
login() {
        this.userService.login(this.user)
            .subscribe(
            (response: any) => {
                this.router.navigate(["/dashboard"]);
            },
            (error) => alert(error)
            );
    }

userService.ts
 return this.http.post(
      url,
      JSON.stringify({
        name: user.email,
        password: user.password
      }),
      {
        headers: new HttpHeaders().set('Content-Type', 'application/json'),
        responseType: 'text'
      }
    )
      .map((response: any) => {
        for (var x in response) {
          if (response.hasOwnProperty(x)) {

          }
        }
        console.log("_body: " + response._body);
        return response._body;
      })
      .catch(this.handleErrors)
  }

A:

NativeScript has exposed the application-settings module. The Application Settings module is used to store strings, booleans, and numbers in a built-in key/value store. Uses SharedPreferences on Android and NSUserDefaults on iOS.
So for example, you could store the login information and use it to check if the user has already been logged in (just as you would do in native Android & iOS projects) - demo POC here

A:

It's good to keep in mind that any keys and values written to the UserDefaults and SharedPreferences, so the native APIs that are used by the application settings module and the getString and setString methods are simply stored on the disk, for anyone with access to the phone to see. This API is not meant for storing sensitive data, and is meant solely for persisting user settings, so 'defaults' and 'preferences'.
If you want a way to securely store email addresses and passwords on the device, take a look at this library: Nativescript-secure-storage. It does a very similar job to the aforementioned APIs but everything is encrypted so people can't just read the contents from the disk.

