OSX: implement OS.get_unique_id
Update the documentations for OS.get_unique_id()
This commit is contained in:
parent
df1c16d0fe
commit
5980bef672
@ -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">
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user