5

Preamble
I'm working on Xcode 7.0.1 with Swift 2

Are hours (update, days) that I try to understand how I can retrieve this information.
I have seen that there is a framework, CoreBluetooth, that maybe could help me. (update, definitely not!!)

Any idea? Objective-c/swift/c/c++.. whatever.. is the same.

I already test code in this answer but prints:

>>> WIFI MAC ADDRESS: 02:00:00:00:00:00
>>> IPHONE BLUETOOTH MAC ADDRESS: 02:00:00:00:00:ffffffff
>>> IPAD BLUETOOTH MAC ADDRESS: 02:00:00:00:00:01

About this, I have read on official documentation:

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.)

The question is: if other devices can read my bluetooth mac address, why I'm not able to?
I think that there should be a way to do it, for sure.

I also try snippets on this answer (and other answers) but I never get real mac address.

I know that to know bluetooth information of mac I can run on terminal:

system_profiler SPBluetoothDataType | sed -n "/Apple Bluetooth Software Version\:/,/Manufacturer\:/p"

And to retrieve mac address only I can 'pipe' to previous command:

egrep -o '([[:xdigit:]]{1,2}-){5}[[:xdigit:]]{1,2}'

I'm asking.. can I run this command on iPhone programmatically?

Actually, I have already tried, with this pseudocode:

script = ""
system("system_profiler SPBluetoothDataType > blueInfo.txt")
sleep
read from file "blueInfo.txt" its content

This code compile and "works", but fail on reading file that does not exist.

I'm currently thinking about dropping ):

Community
  • 1
  • 1
Luca Davanzo
  • 21,000
  • 15
  • 120
  • 146
  • 1
    Apple does not allow developers to identify a device by unique hardware identifiers. It has done so after many misuse of the identifier which could affect the user privacy. – rckoenes Oct 16 '15 at 08:50
  • You can't for privacy reasons. – Larme Oct 16 '15 at 08:53
  • Possible duplicate of [Get MAC address of bluetooth low energy peripheral](http://stackoverflow.com/questions/18973098/get-mac-address-of-bluetooth-low-energy-peripheral) – Magisch Oct 16 '15 at 09:47
  • 1
    @Magisch if you had read what I ask, you would not definitely marked it as duplicate: I asked for my MAC, not peripheral MAC. – Luca Davanzo Oct 16 '15 at 09:51
  • @Velthune : Good research – Ganesh Somani Mar 19 '16 at 04:20

1 Answers1

0

As the commenters and the devs on this GitHub issue have noted, it is impossible to retrieve the MAC address of the current device you're running it on, even though it would be possible to read it off from a second device, due to privacy concerns.

hao
  • 10,138
  • 1
  • 35
  • 50