Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
}
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
}
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");
}
}
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) {
get token() {
return getString(tokenKey);
}
isLoggedIn() {
return !!getString(tokenKey);
}
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);
}
}
}
private _isCurrentVersionSkipped(currentAppStoreVersion: string): boolean {
const lastVersionSkipped = appSettings.getString(LAST_VERSION_SKIPPED_KEY)
return currentAppStoreVersion === lastVersionSkipped
}
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 }
]);
getRememberedEmailForEmailLinkLogin: () => {
return getString("FirebasePlugin.EmailLinkLogin");
},
strongTypeify: value => {