Skip to content

Commit de8cc0d

Browse files
committed
Merge branch 'uuid'
2 parents c5bf366 + ed85fdb commit de8cc0d

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

platform/platform.android.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export class device implements definition.device {
1616
private static _osVersion: string;
1717
private static _sdkVersion: string;
1818
private static _deviceType: string;
19+
private static _uuid: string;
1920

2021
static get os(): string {
2122
return platformNames.android;
@@ -48,7 +49,7 @@ export class device implements definition.device {
4849
static get deviceType(): string {
4950
if (!device._deviceType) {
5051
var dips = Math.min(screen.mainScreen.widthPixels, screen.mainScreen.heightPixels) / screen.mainScreen.scale;
51-
52+
5253
// If the device has more than 600 dips it is considered to be a tablet.
5354
if (dips >= device.MIN_TABLET_PIXELS) {
5455
device._deviceType = enums.DeviceType.Tablet;
@@ -60,6 +61,17 @@ export class device implements definition.device {
6061

6162
return device._deviceType;
6263
}
64+
65+
static get uuid(): string {
66+
if (!device._uuid) {
67+
device._uuid = android.provider.Settings.Secure.getString(
68+
application.android.context.getContentResolver(),
69+
android.provider.Settings.Secure.ANDROID_ID
70+
);
71+
}
72+
73+
return device._uuid;
74+
}
6375
}
6476

6577
var mainScreenInfo: definition.ScreenMetrics;
@@ -80,4 +92,4 @@ export class screen implements definition.screen {
8092
}
8193
return mainScreenInfo;
8294
}
83-
}
95+
}

platform/platform.d.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Contains all kinds of information about the device, its operating system and software.
44
*/
55
declare module "platform" {
6-
6+
77
/*
88
* Enum holding platform names.
99
*/
@@ -45,6 +45,11 @@ declare module "platform" {
4545
* Available values: "phone", "tablet".
4646
*/
4747
static deviceType: string;
48+
49+
/**
50+
* Gets the uuid
51+
*/
52+
static uuid: string;
4853
}
4954

5055
/**
@@ -86,4 +91,4 @@ declare module "platform" {
8691
*/
8792
static mainScreen: ScreenMetrics;
8893
}
89-
}
94+
}

platform/platform.ios.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,21 @@ export class device implements definition.device {
5555

5656
return device._deviceType;
5757
}
58+
59+
static get uuid(): string {
60+
var userDefaults = NSUserDefaults.standardUserDefaults();
61+
var uuid_key = "TNSUUID";
62+
var app_uuid = userDefaults.stringForKey(uuid_key);
63+
64+
if (!app_uuid) {
65+
var uuidRef = CFUUIDCreate(kCFAllocatorDefault);
66+
app_uuid = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
67+
userDefaults.setObjectForKey(app_uuid, uuid_key);
68+
userDefaults.synchronize();
69+
}
70+
71+
return app_uuid;
72+
}
5873
}
5974

6075
var mainScreenInfo: definition.ScreenMetrics = null;

0 commit comments

Comments
 (0)