January 29, 2016
UUID (Universally Unique Identifier) may be generated with:
let uuid = NSUUID().UUIDString
print(uuid)
Result:
19B7xxxx-xxxx-xxxx-xxxx-xxxxxxxx0CFA
===============
Original post:
December 30, 2015
Some device identifiers are now impossible to be obtained from public APIs of iOS:
IMSI - International Mobile Subscriber Identity (SIM card number)
IMEI - International Mobile Equipment Identity (Device ID)
UDID - Unique Device Identifier for Apple iDevices
MAC address - Media Access Control Address (Network address)
IDFV and IDFA are the identifiers available for identification or for advertising:
IDFV (Vendor Identifier / Identifier for Vendor)
IDFV is the same for different apps provided by the same vendor running on the same device.
IDFA (Advertising Identifier / Identifier for Advertising)
IDFA of an iOS device remains the same unless the user make a reset in the Settings app.
IDFV and IDFA can be obtained easily in code. However, IDFA has to be used for advertising. Improper use of IDFA in an app will cause app rejection from the App Store.
How to obtain IDFV / IDFA
Modify ViewController.swift as:
import UIKit
import AdSupport
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let button = UIButton(frame: CGRectMake(70, 100, 200, 20))
button.setTitle("Get IDs", forState: UIControlState.Normal)
button.setTitleColor(UIColor.blueColor(), forState: UIControlState.Normal)
button.setTitleColor(UIColor.cyanColor(), forState: UIControlState.Highlighted)
button.addTarget(self, action: "btnPressed:", forControlEvents: UIControlEvents.TouchUpInside)
view.addSubview(button)
}
func btnPressed(sender: UIButton) {
let strIDFV = UIDevice.currentDevice().identifierForVendor?.UUIDString
print("Vendor = \(strIDFV!)")
var strIDFA : String = "No IDFA"
if ASIdentifierManager.sharedManager().advertisingTrackingEnabled {
strIDFA = ASIdentifierManager.sharedManager().advertisingIdentifier.UUIDString
}
print("IDFA = \(strIDFA)")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
Results
An iPad and an iPhone are tested. The two devices are with different IDFVs and IDFAs.
The IDFV and IDFA are the same for different apps on the same iPhone.
If the "Limit Ad Tracking" option is turned on, there is no IDFA.
If the "Limit Ad Tracking" option is turned off, the IDFA is changed.
If the Advertising Identifier is reset, the IDFA is also changed.
Here are the results of print logs:
iPad
IDFV = C9A9xxxx-xxxx-xxxx-xxxx-xxxxxxF155E6
IDFA = 2544xxxx-xxxx-xxxx-xxxx-xxxxxxFE4B56
iPhone
App #1
IDFV = 912Dxxxx-xxxx-xxxx-xxxx-xxxxxx2332C6
IDFA = CEF5xxxx-xxxx-xxxx-xxxx-xxxxxx8D9C15
App #2
IDFV = 912Dxxxx-xxxx-xxxx-xxxx-xxxxxx2332C6
IDFA = CEF5xxxx-xxxx-xxxx-xxxx-xxxxxx8D9C15
Limit Ad Tracking
Select Settings -> Privacy -> Advertising -> Limit Ad Tracking -> On
IDFV = 912Dxxxx-xxxx-xxxx-xxxx-xxxxxx2332C6
IDFA = No IDFA
Select Settings -> Privacy -> Advertising -> Limit Ad Tracking -> Off
IDFV = 912Dxxxx-xxxx-xxxx-xxxx-xxxxxx2332C6
IDFA = C9ECxxxx-xxxx-xxxx-xxxx-xxxxxxF86A1B
Reset Advertising Identifier
Select Settings -> Privacy -> Advertising -> Reset Advertising Identifier -> Reset Identifier
IDFV = 912Dxxxx-xxxx-xxxx-xxxx-xxxxxx2332C6
IDFA = E8D2xxxx-xxxx-xxxx-xxxx-xxxxxx4A625C
References:
Does this app use the Advertising Identifier (IDFA)? - AdMob 6.8.0
Apple Developers Must Now Agree To Ad Identifier Rules Or Risk App Store Rejection
NSUUID / CFUUIDRef / UIDevice -uniqueIdentifier / -identifierForVendor
The Developer’s Guide to Unique Identifiers
Using CoreTelephony framework to get IMEI and IMSI on iOS 7
No comments:
Post a Comment