23

My app was rejected because of advertisingIdentifier in Facebook sdk and Flurry SDK ! I found an occurrence of advertisingIdentifier in the latest Facebook SDK (3.12) and Flurry SDK. Maybe you can check your library's for an occurence with the method below:

I opened the FacebookSDK.framework as a library in the terminal and typed the following command

otool -v -s __TEXT __objc_methname FacebookSDK | grep advertisingIdentifier

and the same way for Flurry SDK.

But I don't know what to do.?

For news: Flurry has recently updated their SDK and it doesn't contain the advertisingIdentifier, but Facebook didn't yet.

Iulian Onofrei
  • 9,188
  • 10
  • 67
  • 113
chawki
  • 867
  • 1
  • 8
  • 13

4 Answers4

18

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.

Diego
  • 878
  • 9
  • 17
  • 5
    "-weak_framework AdSupport" will come back the next time you run pod update. I added the following script to build phase to fix it automatically: sed -i bak "s/ -weak_framework AdSupport//" Pods/*.xcconfig It doesn't work for the first build after pod update though, so don't archive immediately after pod update. – Haitao Li Mar 06 '14 at 23:25
  • I tried using the FB SDK provided here https://github.com/facebook/facebook-ios-sdk. Unfrotunately the code doesn't seem to be ARC based and it's throwing retain, release errors. Any other code base I can use or how can I fix this? Thank you! – Mobilewits Sep 26 '14 at 02:21
  • 1
    i create last version of command for fix pod update: `find Pods/. -name "*.xcconfig" -type f -print0 | xargs -0 sed -i '' -e "s/-framework\ \"AdSupport\"//" -e "s/-framework\ \"iAd\"//g"` – Bimawa Jan 29 '15 at 12:11
13

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 @"";
}
Andrew
  • 3,166
  • 21
  • 32
  • Does this mean that every apps embedding facebook sdk 3.12 will get rejected because of the piece of code? – grandouassou Feb 05 '14 at 14:29
  • It really depends on Apple's review team. They do miss things from time to time, but the short answer is probably yes. If you display ads - you'll be fine, though. – Andrew Feb 05 '14 at 14:41
  • So Facebook and its sdk assumes every one wants to display ads? Seems weird to me. – grandouassou Feb 05 '14 at 14:46
  • 1
    No, it doesn't. It uses the advertiser identifier only if the setting in Settings isn't limiting its use and even then it's using it for what I assume are valid reasons (like install tracking). The issue here is that Apple wants this identifier used only for the purposes of advertising and if you don't have ads in your app, that means that you're not using it for its intended purpose, hence your app is rejected. – Andrew Feb 05 '14 at 15:19
  • I understand that. But here the advertisingIdentifier is potentially not used at all if I, for example, just retrieve the user's friends list. Despite that my app would be rejected because I include a third party library that make use of this identifier under certain circumstances. Or do I miss something here? – grandouassou Feb 05 '14 at 15:26
  • 2
    Yeah, that's right. Although it's against the Appstore rules, this rule wasn't enforced up until a week ago, so from Facebook's point of view (and a lot of other SDK providers) it was perfectly fine to use it. I do expect them to update their code fairly soon, though. – Andrew Feb 05 '14 at 16:17
  • I download the code and made the changes as specified in FBUtility.m and from scripts i build the script for framework again,then i replaced the framework in my code again. This should work right? – Surender Rathore Feb 11 '14 at 06:50
  • i again tried with the command "grep -r advertisingIdentifier ." it was not showing any matches – Surender Rathore Feb 11 '14 at 06:56
  • Yeah, that should do it as well. To make sure you can set a symbolic breakpoint on advertisingIdentifier and see if it gets hit. – Andrew Feb 11 '14 at 13:58
  • @Andrew, do you know if there's a solution for Facebook SDK for Unity? FacebookSDK.a is referencing ASIndentifierManager. I can't seem to find any. – Psylocke Feb 20 '14 at 10:42
  • Sure, get the ios sdk source code from my answer (make sure to go to the 3.11 release, since that's the on the Unity sdk is based on), go through the procedure to remove the identifier, then compile the iOS library (the .a), it'll generate a libfacebook_ios_sdk.a file, rename it to FacebookSDK.a and replace the one from the Unity package with the new one. Let me know if it works or if you need help with it. – Andrew Feb 20 '14 at 14:09
  • Was someone's app approved using this method ? I'm frustrated, one of my apps got approved with FB 3.11, one rejected. – Nir Golan Feb 23 '14 at 09:42
  • One of my apps got approved yesterday using this method. – Andrew Feb 23 '14 at 10:45
  • How do you compile the IOS library after removing the item? – ORStudios Feb 24 '14 at 16:14
  • After changing the code in FBUtility? Either use the raw source code or use Facebook's project that has a scheme that compiles the library. – Andrew Feb 24 '14 at 17:18
  • @Andrew, I managed to generate the libfacebook_ios_sdk.a. But how can I update the FB files in Unity because they would no longer match the ones from the library, correct? The iOS SDK has a different folder-ing. I'm afraid we had an older Unity SDK(v4.2.4). We didn't update it since they move around the files. We only use FB for login and nothing else and has been working with the 4.2.4 version. Does this mean we have to update first the FB Unity SDK to latest before we can use the library from iOS SDK v3.11? – Psylocke Feb 27 '14 at 14:17
  • Following this solution, I just downloaded the official Facebook SDK sources on their GitHub repository and compiled them back. You can find the build [via this article](http://nscurious.com/2014/10/03/facebook-sdk-without-ad-identifier/). – sweepy_ Oct 03 '14 at 18:21
  • I'm having trouble on compiling the library with the modified class. Does anyone that has it fixed could please send me a download link to it? – Lucas Pereira Dec 05 '14 at 13:39
  • https://github.com/akmarinov/facebook-ios-sdk/blob/master/product/libfacebook_ios_sdk.a is the compiled library, https://github.com/akmarinov/facebook-ios-sdk/tree/master/product/facebook-ios-sdk contains the header files that you'll need – Andrew Dec 05 '14 at 17:58
  • My bad. I freaking missed it :P Thanks a lot! That did the trick. – Lucas Pereira Dec 05 '14 at 18:05
  • That lib is meant to work with any architecture (device/simulator) ? – Lucas Pereira Dec 05 '14 at 18:08
  • I haven't touched FB's settings, so it should be, are you having any issues? – Andrew Dec 05 '14 at 18:13
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/66282/discussion-between-lucas-pereira-and-andrew). – Lucas Pereira Dec 05 '14 at 18:16
2

Just read this:

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

No code changes required.

Juraj Antas
  • 3,059
  • 27
  • 37
  • Whole thread is long. Go straight to this comment from FB for solution: https://developers.facebook.com/bugs/242477629268301/?comment_id=1485600418338719 – Kamil Sarna Sep 16 '16 at 09:21
0

You must delete Facebook-SDK as a bundle version on your project folder and then create a cocoapods and connect last version of these;

 pod 'FBSDKCoreKit'
 pod 'FBSDKShareKit'
 pod 'FBSDKLoginKit'
serdaryillar
  • 413
  • 5
  • 16