Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve iPhone IDFA from API?

I would like to get the device IDFA. How to get this info from iOS official API ?

like image 667
fvisticot Avatar asked Oct 17 '12 22:10

fvisticot


People also ask

How do I find the IDFA on my iPhone?

Find My Apple Device ID The simplest way to locate your iOS device's IDFA is to use a third-party app called The Identifiers. The purpose of the app is to display a device's IDFA, so all you have to do is install and open the app to see your IDFA.

How do I get IDFA on iOS 14?

Apps targeted towards iOS14 will need to use AppTrackingTransparency framework along with AdSupport framework to get the IDFA. AppTrackingTransparency allows developer to request permission from the user to read IDFA instead of just getting the IDFA from the ASIdentifierManager.

Is udid same as IDFA?

In 2012, the UDID was replaced by the IDFA to curb persistent tracking, with Google following suit the next year by releasing an advertising ID for Android to replace its unique Android ID.

How do I get IDFA AppsFlyer?

An AppsFlyer ID is automatically created for every new install of an app. You can use this identifier to perform the following actions: Send server-to-server in-app events. Match AppsFlyer ID with user records in your backend systems.


1 Answers

First, you have to ask permission from the user to use their IDFA:

#import <AppTrackingTransparency/AppTrackingTransparency.h>   [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {  // Tracking authorization completed. Start loading ads here.   }]; 

This permission flow will only run once, the first time it is called, even if you re-start the app and/or call it again. If you want to answer differently, you'll have to delete the app off the device or simulator completely and reinstall it. Note that iOS simulators return blanked IDFAs (all zeroes) no matter what the answer to the permission flow. See https://developer.apple.com/documentation/apptrackingtransparency for details, including how to customize the message shown to users when asking to track them. Note that many advertising SDKs have their own consent flow calls that you can use.

To actually get the IDFA once you have permission:

#import <AdSupport/ASIdentifierManager.h>  

If you would like to get it as an NSString, use:

[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString] 

So your code might look like this:

NSString *idfaString = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; NSLog (@"IDFA: %@", idfaString); 
like image 117
Zachary Drake Avatar answered Oct 13 '22 06:10

Zachary Drake