mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Merge branch 'uuid'
This commit is contained in:
@ -16,6 +16,7 @@ export class device implements definition.device {
|
|||||||
private static _osVersion: string;
|
private static _osVersion: string;
|
||||||
private static _sdkVersion: string;
|
private static _sdkVersion: string;
|
||||||
private static _deviceType: string;
|
private static _deviceType: string;
|
||||||
|
private static _uuid: string;
|
||||||
|
|
||||||
static get os(): string {
|
static get os(): string {
|
||||||
return platformNames.android;
|
return platformNames.android;
|
||||||
@ -60,6 +61,17 @@ export class device implements definition.device {
|
|||||||
|
|
||||||
return device._deviceType;
|
return device._deviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get uuid(): string {
|
||||||
|
if (!device._uuid) {
|
||||||
|
device._uuid = android.provider.Settings.Secure.getString(
|
||||||
|
application.android.context.getContentResolver(),
|
||||||
|
android.provider.Settings.Secure.ANDROID_ID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return device._uuid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mainScreenInfo: definition.ScreenMetrics;
|
var mainScreenInfo: definition.ScreenMetrics;
|
||||||
|
5
platform/platform.d.ts
vendored
5
platform/platform.d.ts
vendored
@ -45,6 +45,11 @@ declare module "platform" {
|
|||||||
* Available values: "phone", "tablet".
|
* Available values: "phone", "tablet".
|
||||||
*/
|
*/
|
||||||
static deviceType: string;
|
static deviceType: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the uuid
|
||||||
|
*/
|
||||||
|
static uuid: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,6 +55,21 @@ export class device implements definition.device {
|
|||||||
|
|
||||||
return device._deviceType;
|
return device._deviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get uuid(): string {
|
||||||
|
var userDefaults = NSUserDefaults.standardUserDefaults();
|
||||||
|
var uuid_key = "TNSUUID";
|
||||||
|
var app_uuid = userDefaults.stringForKey(uuid_key);
|
||||||
|
|
||||||
|
if (!app_uuid) {
|
||||||
|
var uuidRef = CFUUIDCreate(kCFAllocatorDefault);
|
||||||
|
app_uuid = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
|
||||||
|
userDefaults.setObjectForKey(app_uuid, uuid_key);
|
||||||
|
userDefaults.synchronize();
|
||||||
|
}
|
||||||
|
|
||||||
|
return app_uuid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mainScreenInfo: definition.ScreenMetrics = null;
|
var mainScreenInfo: definition.ScreenMetrics = null;
|
||||||
|
Reference in New Issue
Block a user