summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/OS.xml3
-rw-r--r--platform/osx/os_osx.h2
-rw-r--r--platform/osx/os_osx.mm24
3 files changed, 28 insertions, 1 deletions
diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml
index 80febff4af..a61b156b01 100644
--- a/doc/classes/OS.xml
+++ b/doc/classes/OS.xml
@@ -346,7 +346,8 @@
<return type="String">
</return>
<description>
- Returns a string that is unique to the device. Currently only works on Android and iOS. Returns empty string on other platforms.
+ Returns a string that is unique to the device.
+ Returns empty string on HTML5 and UWP which are not supported yet.
</description>
</method>
<method name="get_unix_time" qualifiers="const">
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index d9ad0a7db8..41e0585af6 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -229,6 +229,8 @@ public:
virtual void set_ime_position(const Point2 &p_pos);
virtual void set_ime_intermediate_text_callback(ImeCallback p_callback, void *p_inp);
+ virtual String get_unique_id() const;
+
virtual OS::PowerState get_power_state();
virtual int get_power_seconds_left();
virtual int get_power_percent_left();
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index ab54f62045..56ba80031b 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -963,6 +963,30 @@ void OS_OSX::set_ime_intermediate_text_callback(ImeCallback p_callback, void *p_
}
}
+String OS_OSX::get_unique_id() const {
+
+ static String serial_number;
+
+ if (serial_number.empty()) {
+ io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
+ CFStringRef serialNumberAsCFString = NULL;
+ if (platformExpert) {
+ serialNumberAsCFString = (CFStringRef)IORegistryEntryCreateCFProperty(platformExpert, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0);
+ IOObjectRelease(platformExpert);
+ }
+
+ NSString *serialNumberAsNSString = nil;
+ if (serialNumberAsCFString) {
+ serialNumberAsNSString = [NSString stringWithString:(NSString *)serialNumberAsCFString];
+ CFRelease(serialNumberAsCFString);
+ }
+
+ serial_number = [serialNumberAsNSString UTF8String];
+ }
+
+ return serial_number;
+}
+
void OS_OSX::set_ime_position(const Point2 &p_pos) {
im_position = p_pos;
}