Skip to content

Commit ed85fdb

Browse files
committed
Implement the GUID caching in iOS
1 parent 4bb47f3 commit ed85fdb

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

platform/platform.ios.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,18 @@ export class device implements definition.device {
5757
}
5858

5959
static get uuid(): string {
60-
if (!device._uuid) {
60+
var userDefaults = NSUserDefaults.standardUserDefaults();
61+
var uuid_key = "TNSUUID";
62+
var app_uuid = userDefaults.stringForKey(uuid_key);
63+
64+
if (!app_uuid) {
6165
var uuidRef = CFUUIDCreate(kCFAllocatorDefault);
62-
device._uuid = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
66+
app_uuid = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
67+
userDefaults.setObjectForKey(app_uuid, uuid_key);
68+
userDefaults.synchronize();
6369
}
6470

65-
return device._uuid;
71+
return app_uuid;
6672
}
6773
}
6874

0 commit comments

Comments
 (0)