app rejected because of advertisingIdentifier in Facebook SDK and Flurry SDK

Solution 1:

Update:

Since answering below I have submitted the app to the store, but with the edits suggested below Facebook is able only to track events without doing installation attribution tracking. Thus the problem with the solution below is that it effectively forbids Facebook to link installations to ad campaigngs on facebook.

A fix for this should be using the latest 3.13 Facebook SDK and simply removing the

-weak_framework AdSupport 

from your project as suggested below.

The app now compiles correctly without editing FBUtil.m and it does not link the AdSupport framework is removed from Pods.xconfig and Pods-Facebook-iOS-SDK.xconfig

I left the reply below so that you can see my previous attempt to remove AdSupport from the 3.12 version of the SDK, but DO NOT USE IT if you want to do install ads attribution tracking. (In fact you can use it only if you plan to do CPC ads, otherwise facebook will not be able to optimize the install ads campaigns).

OLD REPLY:

This seemed to be not enough in my case. To be sure, I wanted to remove the AdSupport Framework completely. In the Facebook SDK 3.12 the AdSupport Framework seems to be ALWAYS imported/linked even if it's not included in your project or pod file (in fact I am using cocoapods to install Facebook SDK).

The AdSupport framework was indeed not linked in my project but executing an "otool -L" on my app executable was showing that the framework was still being linked.

In order to avoid the current FB SDK to do that you need to edit the following:

In FBUtility.m

Comment this:

//#import <AdSupport/AdSupport.h>

Edit the following methods:

+ (NSString *)advertiserID {
    /*
    NSString *advertiserID = nil;
    Class ASIdentifierManagerClass = [FBDynamicFrameworkLoader loadClass:@"ASIdentifierManager" withFramework:@"AdSupport"];
    if ([ASIdentifierManagerClass class]) {
        ASIdentifierManager *manager = [ASIdentifierManagerClass sharedManager];
        advertiserID = [[manager advertisingIdentifier] UUIDString];
    }
    return advertiserID;
    */
    return @"";
}

+ (FBAdvertisingTrackingStatus)advertisingTrackingStatus {

    /*
    if ([FBSettings restrictedTreatment] == FBRestrictedTreatmentYES) {
        return AdvertisingTrackingDisallowed;
    }
    FBAdvertisingTrackingStatus status = AdvertisingTrackingUnspecified;
    Class ASIdentifierManagerClass = [FBDynamicFrameworkLoader loadClass:@"ASIdentifierManager" withFramework:@"AdSupport"];
    if ([ASIdentifierManagerClass class]) {
        ASIdentifierManager *manager = [ASIdentifierManagerClass sharedManager];
        if (manager) {
            status = [manager isAdvertisingTrackingEnabled] ? AdvertisingTrackingAllowed : AdvertisingTrackingDisallowed;
        }
    }
    */
    return AdvertisingTrackingDisallowed;
}

Finally if you're using cocoapods search in your project workspace all the

-weak_framework AdSupport

And delete all of those (you'll find those in Pods.xconfig and Pods-Facebook-iOS-SDK.xcconfig)

This has worked for me and now my app executable is free from AdSupport.

Solution 2:

Get the source code from https://github.com/facebook/facebook-ios-sdk , instead of the compiled framework. Just deleting the framework and pasting in the source code should do it.

Go to FBUtility.m and modify this method:

+ (NSString *)advertiserID {
    NSString *advertiserID = nil;
    Class ASIdentifierManagerClass = [FBDynamicFrameworkLoader loadClass:@"ASIdentifierManager" withFramework:@"AdSupport"];
    if ([ASIdentifierManagerClass class]) {
        ASIdentifierManager *manager = [ASIdentifierManagerClass sharedManager];
        advertiserID = [[manager advertisingIdentifier] UUIDString];
    }
    return advertiserID;
}

to

+ (NSString *)advertiserID {
   return @"";
}

Solution 3:

Just read this:

https://developers.facebook.com/bugs/242477629268301/

No code changes required.