
- iOS Tutorial
- iOS - Home
- iOS - Getting Started
- iOS - Environment Setup
- iOS - Objective-C Basics
- iOS - First iPhone Application
- iOS - Actions and Outlets
- iOS - Delegates
- iOS - UI Elements
- iOS - Accelerometer
- iOS - Universal Applications
- iOS - Camera Management
- iOS - Location Handling
- iOS - SQLite Database
- iOS - Sending Email
- iOS - Audio & Video
- iOS - File Handling
- iOS - Accessing Maps
- iOS - In-App Purchase
- iOS - iAd Integration
- iOS - GameKit
- iOS - Storyboards
- iOS - Auto Layouts
- iOS - Twitter & Facebook
- iOS - Memory Management
- iOS - Application Debugging
- iOS Useful Resources
- iOS - Quick Guide
- iOS - Useful Resources
- iOS - Discussion
How to get the MAC address of an iOS/iPhone programmatically?
In iOS versions previous to 7.0 getting the MAC address of device was possible. But with new iOS version it has been disabled for the apps to access MAC address of the device.
When it is accessed or requested on current version of iOS it always returns 02:00:00:00:00:00. This has been implemented by apple because of privacy concerns. If your app needs to uniquely identify a device, apple recommends to use UDID/ UUID instead of MAC. In swift we can use
UIDevice.current.identifierForVendor Which as per apple documentation says that, The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor.
UIDevice.current.identifierForVendor?.uuidString – returns a string value for the UUID.
We can use them in our application like
override func viewDidLoad() { super.viewDidLoad() print(UIDevice.current.identifierForVendor) print(UIDevice.current.identifierForVendor?.uuidString) }
When run on an iOS 12.0 simulator on iPhone 7 Plus, it gives the following result
Optional(1E52E5F9-9385-4269-A2CA-A0B9063DCBA5) Optional("1E52E5F9-9385-4269-A2CA-A0B9063DCBA5
- Related Articles
- How to take a screenshot programmatically in iPhone/iOS?
- How to get the IP address of android device programmatically?
- How to get current Wi-Fi mac address in android?
- How to get the IP address of the Android device programmatically using Kotlin?
- How to Extracting MAC address using Python?
- How to find the MAC address of the system using PowerShell?
- How do I programmatically “restart” an iOS app?
- How to parse JSON object in iPhone/iOS?
- How to compare two NSDates in iPhone/iOS?
- How to create a WebView in iOS/iPhone?
- How to access RESTFul services from iOS/iPhone?
- How to lock & unlock the iOS device programmatically
- Difference between IP Address and MAC Address
- Difference between MAC Address and IP Address
- How to obtain the phone number of the iOS phone programmatically?
