Search code examples
swiftwatchkitwatchos

How to get the device id from watch os swift


Hey I am developing a watch application and I want to get the device id of the device. But when I try to access using "UIDevice.current" it gives an error that UIDevice is not within scope. Am I doing something wrong or is it somehow restricted for obtaining those information? How can I obtain that information? Thanks in advance

enter image description here


Solution

  • For anyone who is also stucked with the above scenario,You can easily achieve the device id by

    let deviceId = WKInterfaceDevice.current().identifierForVendor?.uuidString ?? ""