If you open Settings -> General -> About, it'll say Bob's iPhone at the top of the screen. How do you programmatically grab that name?
If you open Settings -> General -> About, it'll say Bob's iPhone at the top of the screen. How do you programmatically grab that name?
From the UIDevice class:
Swift version:
UIDevice.current.name
Objective-C version:
[[UIDevice currentDevice] name];
The UIDevice is a class that provides information about the iPhone or iPod Touch device.
Some of the information provided by UIDevice is static, such as device name or system version.
source: http://servin.com/iphone/uidevice/iPhone-UIDevice.html
Offical Documentation: Apple Developer Documentation > UIDevice Class Reference
For swift4.0 and above used below code:
let udid = UIDevice.current.identifierForVendor?.uuidString
let name = UIDevice.current.name
let version = UIDevice.current.systemVersion
let modelName = UIDevice.current.model
let osName = UIDevice.current.systemName
let localized = UIDevice.current.localizedModel
print(udid ?? "") // ABCDEF01-0123-ABCD-0123-ABCDEF012345
print(name) // Name's iPhone
print(version) // 14.5
print(modelName) // iPhone
print(osName) // iOS
print(localized) // iPhone
Device Name would not work out of Box now, Need to have a special entitlement.
Entitlement : com.apple.developer.device-information.user-assigned-device-name
Doc : https://developer.apple.com/forums/thread/708275
Official : https://developer.apple.com/documentation/uikit/uidevice/1620015-name