How to get the wifi mac address on iPhone in Swift? - ios

Is there a way to get the real Wi-Fi MAC address of the IOS device using Swift language?
Code snippet much appreciated!
Thanks.

When you request the Device MAC address in iOS 7 and above you will always get the same response: 02:00:00:00:00:00, this has been made by Apple for privacy concerns.
In iOS 7 and later, if you ask for the MAC address of an iOS device, the system returns the value 02:00:00:00:00:00. If you need to identify the device, use the identifierForVendor property of UIDevice instead. (Apps that need an identifier for their own advertising purposes should consider using the advertisingIdentifier property of ASIdentifierManager instead.)
Apple recommends to switch to UDID instead if you need to uniquely identify an iOS device. In Swift you can use this:
UIDevice.currentDevice().identifierForVendor
if you want a string instead use:
UIDevice.currentDevice().identifierForVendor.UUIDString
Here's a nice reading about UDID

This is no longer possible since iOS 7, due to privacy risks Apple does not allow developers to access any device specific identifiers.

You can not get mac address because of some security concerns. you may use UUID instead to identify device uniquely.
for swift 4.2
UIDevice().identifierForVendor?.uuidString ?? ""
for objective c
[[[UIDevice currentDevice] identifierForVendor] UUIDString]

For iOS 15 do this:
UIDevice.current.identifierForVendor?.uuidString

Related

does Apple allows to display MAC address of devices in app

I thought this could be best place to clarify my doubts and my concern - we about to release our app and it displays MAC address of all connected devices to a router and someone told me apple does not allow to display MAC address and hence app will get rejected.
But there are so many ios apps on itunes which does display MAC address and how did there app got approved if apple does not allow it.
Please guide me on this.
Thanks,
From iOS 7 or later, the MAC address of an iOS device always returns value 02:00:00:00:00:00. If you need to identify the device, use the identifierForVendor property of UIDevice instead.([[UIDevice currentDevice] uniqueIdentifier]).

Reading/writing Device Name characteristic of BLE Device in iOS 7

I want to rename the device name of BLE Device. In iOS 6.1.3, I am able to write the "Device Name" Characteristic of Generic Access Profile Service. But in iOS 7 and later, CBPeripheral is unable to discover the Generic Access Profile Service(1800).
My Question is that Is it possible to read/write Device Name characteristic of BLE Device in iOS 7? If it is possible, then how can I do that? If apple has removed this support in iOS7 and greater, then what is alternate to do this?
iOS prevents that Service from being usable by a developer. Section 3.12 (page 24) documents the fact iOS does not let a developer use that Service (and a couple others) https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf
I ended up making a custom Characteristic that an app could write to. The firmware would handle that write request and then update the device name and advertising packet. It's seems hacky, but I wasn't able to find a better solution. It's unfortunate that iOS blocks this because it makes it impossible to make a device that is compatible with other apps unless someone makes a separate 'custom device name' standard or something...

objective C iOS Device ID in iOS7

I want to ask that whether objective C can obtain a unique device ID of the Device. "uniqueIdentifier" is deprecated in iOS7 and I try to use "identifierForVendor" but it gives me a different ID after the app is re-installed. I want to find a stable device ID after the app is re-install, and even the iOS is changed. In the early version of iOS, we can use MAC address to achieve such goal. But now, in iOS7, the MAC address is no longer available. How can i find a stable device ID of the iOS device in iOS7?
Maybe using Keychain to store the "identifierForVendor" value is a good approach. But will it still be the same after the whole iOS is re-installed?
iOS does not allow you to identify a device universally anymore. That is the basic idea behind removing access to UDID and Mac address.
You need to change the design of your application to adapt to these new circumstances.
in my case i used keyChain to save first generated UUID then i used it as unique device id it still persistent even if after uninstalling the app

Trouble with MAC address in iOS 7.0.2

From iOS 7.0.2 the MAC address is: 02:00:00:00:00:00.
How can I read real one in iOS?
Is this unvailable from 7.0.2, or not?
How do it?
This is a privacy change, so there's no way to get at the underlying MAC address. https://developer.apple.com/news/?id=8222013a
If your apps use the MAC address to identify an iOS device, the system will return the same static value for all devices running iOS 7. Please update your apps to use the identifierForVendor property of UIDevice. If you need an identifier for advertising purposes, use the advertisingIdentifier property of ASIdentifierManager.

How to identify an Enterprise (corporate) iOS device from an app?

I'm working on some apps for distribution through the Enterprise program onto company iPads (so I / the company has complete control over them). What is the "correct", if there is one, way to identify the device that the apps are running on, in the context of corporate owned devices?
CFUUIDCreate as recommended here UIDevice uniqueIdentifier Deprecated - What To Do Now? won't work, as the id has to be the same across several apps.
Right now How can I programmatically get the MAC address of an iphone looks like the best way, but I'm very new to Apple stuff and would like to know if there is a better way.
The iPads are for warehouse use, and id'ing the device is to id which warehouse that iPad is assigned to.
We are using OpenUDID in our projects for persistent cross-app identifier as a drop-in replacement for deprecated UDID.
Usage:
#include "OpenUDID.h"
NSString* openUDID = [OpenUDID value];
I run an enterprise program as well and you're right, the new UUID pieces Apple provides aren't useful. Not only are they not the same across apps but they aren't the same if the user deletes and redownloads your enterprise app.
Since you're not distributing through the App Store, you won't get shut down for using the [UIDevice uniqueIdentifier] and it still does work in iOS today. I personally send that and the MAC address and cross my fingers that this will continue to work in future releases. It's possible that Apple starts returning #"" or some other null string for the UUID in the future so be prepared.
With iOS7 (beta) UIDevice uniqueIdentifier now behaves like identifierForVendor. i.e. The ID will differ for each app and also will be reset when the app is reinstalled.

Resources