简体   繁体   中英

Facebook SDK for Unity makes calls before initialization

I developed a Unity app that uses the Facebook SDK. Everything is going fine, except that I'm seeing traffic leave my app, sending advertiser_id information to Facebook even before I formally initialize the Facebook SDK.

This causes serious problems if the application is for kids under 13 because it sends an id for a user that should not be tracked. Is there a way to restrict these calls from happening or to only happen after the SDK is formally initialized and not when the app boots up?

Here's a sample call of what I'm seeing:

POST /v2.8/XXXXXXXXXXXXXXX/activities?advertiser_id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&advertiser_tracking_enabled=1&anon_id=XXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&application_tracking_enabled=1&event=MOBILE_APP_INSTALL&extinfo=XXXXXXXXXXXXXXXXXXXXXXXX&format=json&include_headers=false&sdk=ios&url_schemes=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
HTTP/1.1
Host: graph.facebook.com
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; 
Accept-Language: en-gb
Content-Length: 1378
Accept: */*
Connection: keep-alive
User-Agent: FBiOSSDK.4.17.0

sdk ios
advertiser_tracking_enabled 1
format  json
include_headers false
anon_id XXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
application_tracking_enabled    1
event   MOBILE_APP_INSTALL
extinfo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
url_schemes XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
advertiser_id   XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

Obviously I cannot turn off tracking for these calls if the SDK hasn't been formally initialized.

Integrating the SDK without any other work causes this issue. However, the only way around it is to directly modify the native code in XCode for iOS.

You have to go to the file FacebookSDK/SDK/Editor/iOS/FBUnityInterface.mm and modify the following function from this

- (void)didBecomeActive:(NSNotification *)notification
{
  [FBSDKAppEvents activateApp];
}

to this

- (void)didBecomeActive:(NSNotification *)notification
{
//  [FBSDKAppEvents activateApp];
}

Otherwise events will trigger right as you boot the app, without asking for an age gate. Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM