iOS Advertising Identifier rejection FAQ

Recently we received several reports that Apple started rejecting apps that use iOS Advertising Identifier, but do not show advertisements. If you was affected by this issue there are instructions how to remove use of this API from Xcode project produced by Unity.

  1. Locate DeviceSettings.mm file in your Xcode project (you should find it under Classes/Unity/)

  2. Make following modifications there:
    a)Remove following functions:

static id QueryASIdentifierManager()
{
<..>
}
static void QueryAdID()
{
<..>
}
static void QueryAdTracking()
{
<..>
}

b) Remove following declarations of variables:

static NSString*	_ADID				= nil;
static bool			_AdTrackingEnabled	= false;

c) Modify implementations of following functions (replace with provided below):

extern "C" const char*	UnityAdvertisingIdentifier()
{
return NULL;
}

extern "C" bool 		UnityAdvertisingTrackingEnabled()
{
return false;
}

static void QueryDeviceID()
{
	if(_DeviceID == nil)
	{
	#if UNITY_PRE_IOS7_TARGET
		if(!_ios70orNewer)
			_InitDeviceIDPreIOS7();
	#endif

		// first check vendor id
		if(_DeviceID == nil)
		{
			QueryVendorID();
			_DeviceID = _VendorID;
		}
	}
}

P.S. many other 3rd party libraries are using this API too, so consider contacting their providers if solution posted above doesn’t help.
P.P.S. we are working to release this fix ASAP

P.P.P.S.
Solution posted above needs to be applied for every fresh build when Xcode project gets replaced from scratch or is deployed to new folder. To make these changes permanent for all future builds you should update master template for this file, which you can find at /Applications/Unity/Unity.app/Contents/PlaybackEngines/iPhonePlayer/iPhone-Trampoline/Classes/Unity

Thx.
I’ll try.

I want to ask this to Unity that is it confirmed that after changing the DeviceSettings.mm file as you mentioned, apple will not reject the app anymore?

I tried the above but now I receive compiler errors in Xcode. Please help.

/Classes/Unity/DeviceSettings.mm:31:13: Function ‘QueryDeviceID’ has internal linkage but is not defined

Undefined symbols for architecture armv7:
“_UnityAdvertisingTrackingEnabled”, referenced from:
IsAdvertisingTrackingEnabled() in libiPhone-lib.a(LibEntryPoint.o)
HardwareInfoReporter::ReportHardwareInfo() in libiPhone-lib.a(ReportHardware.o)
“_UnityAdvertisingIdentifier”, referenced from:
GetAdvertisingIdentifier() in libiPhone-lib.a(LibEntryPoint.o)
HardwareInfoReporter::ReportHardwareInfo() in libiPhone-lib.a(ReportHardware.o)
“QueryDeviceID()”, referenced from:
_UnityDeviceUniqueIdentifier in DeviceSettings.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I believe, you missed part c) of the instructions.

You are correct, my bad. Thanks for this solution!

Our app just got approved this morning by using the method posted here.

I am using chartboost SDK in my unity3D engine. I am not getting any help from chartboost help community. I am not understanding now that this issue (iAd rejection) is now regarding to chartboost integration or is it bug from Unity iteself. Please help because we are at the submission of the app and getting already very late.

First, it’s not nice to post all in large size font. Second this is not really Unity only issue and Mantas already provided everyone a solution for Unity base code however they are not responsible or can’t resolve 3rd party plugin problems. You need to get a solution from Chartboost or you need to stop using it. That means you postpone your release until they fix it or you try to fix it yourself if they provide code or find other product to do the same.

The problem relates to Apples new policy the enforce the rule they have told about before:

I tried the solution and used “grep -r advertisingIdentifier .” to test my binary. I got this:

Binary file ./Data/Managed/UnityEngine.dll matches
Binary file ./Libraries/libiPhone-lib.a matches
./Libraries/RegisterMonoModules.cpp: void Register_UnityEngine_iPhone_get_advertisingIdentifier ();
./Libraries/RegisterMonoModules.cpp: Register_UnityEngine_iPhone_get_advertisingIdentifier ();
./Libraries/UnityEngine.dll.s:m_wrapper_managed_to_native_UnityEngine_iPhone_get_advertisingIdentifier:
./Libraries/UnityEngine.dll.s: plt__icall_native_UnityEngine_iPhone_get_advertisingIdentifier:

Dose it mean my binary still use iOS Advertising Identifier?

I’ve did everything according to the FAQ but when i launch the game (debug mode), splash screen comes up, bloody error comes up (debug mode says that error comes up in “checkBytes” ) how can i fix this?

I believe your error is unrelated. Most probably you are on iOS Free license and have inappropriate splashscreen installed. Maybe you were on iOS Pro trial when started your project?

You should be fine.

Yes i’m using iOS Free license and splashscreen set by default. When i follow this faq, my project doesn’t work. when i don’t it works fine.

I get this result when I try to build the build after modifiying the .mm source to what was described.

Undefined symbols for architecture armv7:
“_UnityDeviceUniqueIdentifier”, referenced from:
systeminfo::GetDeviceUniqueIdentifier() in libiPhone-lib.a(iPhoneSettings.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I had commented out : extern “C” const char* UnityDeviceUniqueIdentifier()
block… dont do that :slight_smile:

@Mantas,

I’ve already implemented this fix on our project, but at one part, we use SystemInfo.deviceUniqueIdentifier(for Push notification-related purposes). Will this give us trouble if we use the device ID even if we are not using ads on our app?

With this fix SystemInfo.deviceUniqueIdentifier uses only identifierForVendor, so you should be OK.

my app has to use ad tracking, but doesn’t show any ads. After deleting the codes above, will ad tracking still work?