Integración

Puedes inicializar el plugin usando el AppsFlyerObject prefab o manualmente.

Uso de AppsFlyerObject.prefab

  1. Ve a Assets > AppsFlyer y arrastra AppsFlyerObject.prefab a tu escena.


  2. Actualiza los siguientes campos:
ConfiguraciónDescripción
Dev keyClave de desarrollador de AppsFlyer, a la que se puede acceder desde el panel de control de AppsFlyer.
App IDTu ID de aplicación de iTunes. (Si tu aplicación no es para iOS, deja el campo vacío)
Obtener datos de conversiónEstablece esto en true si tu aplicación está usando AppsFlyer para enlaces profundos.
isDebugEstablece esto en true para ver los registros de depuración. (¡solo para el desarrollo!)
  1. Actualiza el código en Assets > AppsFlyer > AppsFlyerObjectScript.cs con otra API disponible.

Integración manual

Crea un objeto de juego y agrega el siguiente código de inicio:

using AppsFlyerSDK;

public class AppsFlyerObjectScript : MonoBehaviour
{
  void Start()
  {
    AppsFlyer.initSDK("devkey", "appID");
    AppsFlyer.startSDK();
  }
}

Nota:

  • Asegúrate de no eliminar el objeto de juego.
  • Use DontDestroyOnLoad para mantener el objeto al cargar una nueva escena.

Set customer user ID

Set your own unique customer user ID (CUID) and cross-reference it with the unique AppsFlyer ID.

  • Appear in AppsFlyer raw data CSV reports.
  • Can be used in postback APIs to cross-reference with internal IDs.
    To set the CUID, use:
AppsFlyer.setCustomerUserId("someId");

Good practice! Set the CUID early in the app flow—it is only associated with events reported after its setup.

  • Recorded events will be associated with the CUID.
  • Related data will appear in the raw data reports for installs and events..

Associate the CUID with the install event

If it’s important for you to associate the install event with the CUID, call setCustomerUserId antes de llamar a startSDK.

Recopilar el IDFA con ATTrackingManager

  1. Agrega AppTrackingTransparency a tu proyecto de xcode.

  2. En el Info.plist:

    1. Agrega una entrada a la lista: presiona + junto a Information Property List.
    2. Desplázate hacia abajo y selecciona Privacy - Tracking Usage Description.
    3. Agrega como valor el texto que quieras presentarle al usuario al solicitar permiso para recopilar el IDFA.
  3. Llama a la API waitForATTUserAuthorizationWithTimeoutInterval antes de startSDK()

    #if UNITY_IOS && !UNITY_EDITOR
    AppsFlyer.waitForATTUserAuthorizationWithTimeoutInterval(60);
    #endif
    
  4. Solicita la autorización de tracking donde desees mostrar el aviso:

    Puedes usar el siguiente paquete o cualquier otro paquete que te permita solicitar la autorización de tracking.

    
    using Unity.Advertisement.IosSupport;
    
    /*  ... */
    
    if (ATTrackingStatusBinding.GetAuthorizationTrackingStatus() 
         == ATTrackingStatusBinding.AuthorizationTrackingStatus.NOT_DETERMINED)
        {
            ATTrackingStatusBinding.RequestAuthorizationTracking();
        }
     /*  ... */
    

Send consent for DMA compliance

Unity SDK plugin offers two alternative methods for gathering consent data:

Through a Consent Management Platform (CMP): If the app uses a CMP that complies with the Transparency and Consent Framework (TCF) v2.2 protocol, the Unity SDK can automatically retrieve the consent details.

OR

Through a dedicated Unity SDK API: Developers can pass Google's required consent data directly to the Unity SDK using a specific API designed for this purpose.

Use CMP to collect consent data

  1. Inicializa el SDK.

  2. Call enableTCFDataCollection(true) api before startSDK() to instruct the SDK to collect the TCF data from the device.

  3. Use the CMP to decide if you need the consent dialog in the current session to acquire the consent data. If you need the consent dialog move to step 4; otherwise move to step 5.

  4. Get confirmation from the CMP that the user has made their consent decision and the data is available.

  5. Call start().

        AppsFlyer.initSDK(devKey, appID, this);
    
        AppsFlyer.enableTCFDataCollection(true);
        
        //YOUR_CMP_FLOW()
        // if already has consent ready - you can start
            AppsFlyer.startSDK();
            
        //else Waiting for CMP completion and data ready and then start
        
            AppsFlyer.startSDK();
    

Manually collect consent data

  1. Inicializa el SDK.
  2. Determine whether the GDPR applies or not to the user.

When GDPR applies to the user

  1. Given that GDPR is applicable to the user, determine whether the consent data is already stored for this session.
    i. If there is no consent data stored, show the consent dialog to capture the user consent decision.
    ii. If there is consent data stored continue to the next step.

  2. To transfer the consent data to the SDK create an AppsFlyerConsent object with the following parameters:

    • hasConsentForDataUsage - Indicates whether the user has consented to use their data for advertising purposes.
    • hasConsentForAdsPersonalization - Indicates whether the user has consented to use their data for personalized advertising.
  3. Call setConsentData()with the AppsFlyerConsent object.

  4. Call start().

            
        // If the user is subject to GDPR - collect the consent data
        // or retrieve it from the storage
        ...
        // Set the consent data to the SDK:
        AppsFlyerConsent consent = AppsFlyerConsent.ForGDPRUser(true, true);
        AppsFlyer.setConsentData(consent);
            
        AppsFlyer.startSDK();
    

When GDPR does not apply to the user

  1. Create an AppsFlyerConsent object using the ForNonGDPRUser() initializer. This initializer doesn’t accept any parameters.

  2. Pass the empty AppsFlyerConsent object to setConsentData().

  3. Call start().

        // If the user is not subject to GDPR:
        AppsFlyerConsent consent = AppsFlyerConsent.ForNonGDPRUser();
        AppsFlyer.setConsentData(consent);
            
        AppsFlyer.startSDK();
    

Verify consent data is sent

To test whether your SDK sends DMA consent data with each event, perform the following steps:

  1. Enable the SDK debug mode.
  2. Search for consent_data in the log of the outgoing request.

for more information visit iOS
Android


Enviar el postback de SKAN a AppsFlyer

Para registrar el punto de conexión de AppsFlyer, es necesario agregar la clave NSAdvertisingAttributionReportEndpoint a tu info.plist y establecer el valor en https://appsflyer-skadnetwork.com/.
Para más información sobre cómo actualizar la info.plist, consulta aquí.


Inicialización MacOS

  1. Utilizar el prefab AppsFlyerObject
  2. Agrega tu id de aplicación MacOS
  3. Construye para la plataforma PC, Mac & Linux Standelone y elige MacOS como plataforma de destino.

Agentes de escucha de solicitudes (opcional)

  1. Adjunta el 'AppsFlyer.cs' al objeto del juego con el código init de AppsFlyer. (AppsFlyerObject, etc.)
  2. Agrega el siguiente código antes de startSDK()

Ejemplo de respuesta a las sesiones:

    void Start()
    {
        AppsFlyer.OnRequestResponse += AppsFlyerOnRequestResponse;
        
        AppsFlyer.initSDK(devKey, appID, this);
        AppsFlyer.startSDK();
    }

    void AppsFlyerOnRequestResponse(object sender, EventArgs e)
    {
        var args = e as AppsFlyerRequestEventArgs;
        AppsFlyer.AFLog("AppsFlyerOnRequestResponse", " status code " + args.statusCode);
    }

Ejemplo de respuesta in-app:

    void Start()
    {
        AppsFlyer.OnInAppResponse += (sender, args) =>
        {
            var af_args = args as AppsFlyerRequestEventArgs;
            AppsFlyer.AFLog("AppsFlyerOnRequestResponse", " status code " + af_args.statusCode);
        };
        
        AppsFlyer.initSDK(devKey, appID, this);
        AppsFlyer.startSDK();
    }


statusCodeerrorDescription
200null
10"Event timeout. Check 'minTimeBetweenSessions' param" ("Tiempo de espera del evento agotado. Comprueba el parámetro 'minTimeBetweenSessions'")
11"Skipping event because 'isStopTracking' enabled" ("Se omite el evento porque 'isStopTracking' está activado")
40Network error: Error description comes from Android (Error de red: la descripción del error viene de Android)
41"No dev key" ("No hay clave de desarrollador")
50"Status code failure" + actual response code from the server ("Fallo del código de estado" + código de respuesta real del servidor)