How to use the tns-core-modules/application-settings.getString function in tns-core-modules

To help you get started, we’ve selected a few tns-core-modules examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NativeScript / nativescript-sdk-examples-ng / app / ng-framework-modules-category / application-settings / values / values.component.ts View on Github external
this.username = getString("username");
        // << app-settings-string-code

        // >> app-settings-number-code
        setNumber("locationX", 54.321);
        this.locationX = parseFloat(getNumber("locationX").toFixed(3));
        // << app-settings-number-code

        // >> app-settings-default-value-code
        // will return "No string value" if there is no value for "noSuchKey"
        this.someKey = getString("noSuchKey", "No string value");
        // << app-settings-default-value-code

        // >> app-settings-no-value-code
        // will return undefined if there is no value for "noSuchKey"
        let defaultValue = getString("noSuchKey");
        console.log(defaultValue);
        // << app-settings-no-value-code

        // >> app-settings-no-key-code
        // will return false if there is no value for "noBoolKey"
        this.noBoolKey = hasKey("noBoolKey");
        // << app-settings-no-key-code
    }
github NativeScript / nativescript-sdk-examples-ng / app / ng-framework-modules-category / application-settings / values / values.component.ts View on Github external
this.isTurnedOn = getBoolean("isTurnedOn", true);
        // << app-settings-bool-code

        // >> app-settings-string-code
        setString("username", "Wolfgang");
        this.username = getString("username");
        // << app-settings-string-code

        // >> app-settings-number-code
        setNumber("locationX", 54.321);
        this.locationX = parseFloat(getNumber("locationX").toFixed(3));
        // << app-settings-number-code

        // >> app-settings-default-value-code
        // will return "No string value" if there is no value for "noSuchKey"
        this.someKey = getString("noSuchKey", "No string value");
        // << app-settings-default-value-code

        // >> app-settings-no-value-code
        // will return undefined if there is no value for "noSuchKey"
        let defaultValue = getString("noSuchKey");
        console.log(defaultValue);
        // << app-settings-no-value-code

        // >> app-settings-no-key-code
        // will return false if there is no value for "noBoolKey"
        this.noBoolKey = hasKey("noBoolKey");
        // << app-settings-no-key-code
    }
github NativeScript / nativescript-sdk-examples-ng / app / ng-framework-modules-category / application-settings / values / values.component.ts View on Github external
public onClearSettings() {
        // >> app-settings-remove-key-code
        remove("isTurnedOn");
        // << app-settings-remove-key-code

        // >> app-settings-remove-all-code
        clear();
        // << app-settings-remove-all-code

        setBoolean("isTurnedOn", false);
        this.isTurnedOn = getBoolean("isTurnedOn", false);

        setString("username", "Default name");
        this.username = getString("username");

        setNumber("locationX", 0.00);
        this.locationX = parseFloat(getNumber("locationX").toFixed(2));

        this.someKey = getString("noSuchKey", "No string value");
        this.noBoolKey = hasKey("noBoolKey");
    }
}
github NativeScript / nativescript-facebook / demo-angular / app / pages / home / home.component.ts View on Github external
import { Component, ChangeDetectorRef } from "@angular/core";
import * as Facebook from "nativescript-facebook";
import { NavigationService } from "../../services/navigation.service";
import { config } from "../../app.config";
import * as http from "tns-core-modules/http";
import * as appSettings from "tns-core-modules/application-settings";

@Component({
    selector: "home",
    moduleId: module.id,
    templateUrl: "home.component.html",
    styleUrls: ["home.component.css"]
})
export class HomeComponent {
    accessToken: string = appSettings.getString("access_token");
    userId: string;
    username: string;
    avatarUrl: string;

    constructor(private ref: ChangeDetectorRef, private navigationService: NavigationService) {
        // Get logged in user's info
        http.getJSON(config.FACEBOOK_GRAPH_API_URL + "/me?access_token=" + this.accessToken).then((res) => {
            this.username = res["name"];
            this.userId = res["id"];

            // Get logged in user's avatar
            // ref: https://github.com/NativeScript/NativeScript/issues/2176
            http.getJSON(config.FACEBOOK_GRAPH_API_URL + "/" + this.userId + "/picture?type=large&redirect=false&access_token=" + this.accessToken).then((res) => {
                this.avatarUrl = res["data"]["url"];
                this.ref.detectChanges();
            }, function (err) {
github halfnelson / svelte-native-realworld / app / stores / user.ts View on Github external
function buildUserTokenStore() {
    var stored_token = appSettings.getString('user_token', null);
    const user_token = writable(stored_token);
    return {
        subscribe: user_token.subscribe,
        set(value: string) {
            if (value) {
                appSettings.setString('user_token', value); 
            } else {
                appSettings.remove('user_token');
            }
            user_token.set(value);
        }
    }
}
github chronogolf / nativescript-store-update / src / store-update.common.ts View on Github external
private _isCurrentVersionSkipped(currentAppStoreVersion: string): boolean {
    const lastVersionSkipped = appSettings.getString(LAST_VERSION_SKIPPED_KEY)
    return currentAppStoreVersion === lastVersionSkipped
  }
github NickIliev / nativescript-ng-cosmos / app / services / login.service.ts View on Github external
google(routerExtensions: any) {
        if (getBoolean("isLogged")) {
            let uid = getString("uid");
            let username = getString("username");
            let userPicture = getString("userPicture");

            this._appCenter.trackEvent("Google Login", [
                { key: "user", value: username }
            ]);

            this.authenticateAction(routerExtensions, uid, username, userPicture);
        } else {
            providerLogin({
                type: LoginType.GOOGLE
            }).then((result) => {
                let user: User = result;
                this._appCenter.trackEvent("Google Login", [
                    { key: "user", value: user.displayName }
                ]);
github EddyVerbruggen / nativescript-plugin-firebase / src / firebase-common.ts View on Github external
getRememberedEmailForEmailLinkLogin: () => {
    return getString("FirebasePlugin.EmailLinkLogin");
  },
  strongTypeify: value => {