Integração

You can initialize the plugin by using the AppsFlyerObject prefab or manually.

Using the AppsFlyerObject.prefab

  1. Go to Assets > AppsFlyer and drag AppsFlyerObject.prefab to your scene.


  2. Update the following fields:
ConfiguraçãoDescrição
Dev KeyAppsFlyer's Dev Key, which is accessible from the AppsFlyer dashboard.
App IDYour iTunes Application ID. (If your app is not for iOS the leave field empty)
Get Conversion DataSet this to true if your app is using AppsFlyer for deep linking.
isDebugSet this to true to view the debug logs. (for development only!)
  1. Update the code in Assets > AppsFlyer > AppsFlyerObjectScript.cs with other available API.

Manual integration

Crie um objeto de jogo e adicione o seguinte código de init:

using AppsFlyerSDK;

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

Observação:

  • Make sure not to call destroy on the game object.
  • Use DontDestroyOnLoad to keep the object when loading a new scene.

Collect IDFA with ATTrackingManager

  1. Adicione o AppTrackingTransparency framework to your xcode project.

  2. In the Info.plist:

    1. Add an entry to the list: Press + next to Information Property List.
    2. Scroll down and select Privacy - Tracking Usage Description.
    3. Add as the value the wording you want to present to the user when asking for permission to collect the IDFA.
  3. Call the waitForATTUserAuthorizationWithTimeoutInterval api before startSDK()

    #if UNITY_IOS && !UNITY_EDITOR
    AppsFlyer.waitForATTUserAuthorizationWithTimeoutInterval(60);
    #endif
    
  4. Reques the tracking authorization where you wish to display the prompt:

    You can use the following package or any other package that allows you to request the tracking authorization.

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

Sending SKAN postback to Appsflyer

To register the AppsFlyer endpoint, you need to add the NSAdvertisingAttributionReportEndpoint key to your info.plist and set the value to https://appsflyer-skadnetwork.com/.
More info on how to update the info.plist can be found here.


MacOS initialization

  1. Use the prefab AppsFlyerObject
  2. Add your MacOS app id
  3. Build for the platform PC, Mac & Linux Standelone and choose MacOS as the target platform.

Request Listeners (Optional)

  1. Attach the 'AppsFlyer.cs' script to the game object with the AppsFlyer init code. (AppsFlyerObject, ect)
  2. Add the following code before startSDK()

Sessions response example:

    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);
    }

In-App response example:

    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" ("Tempo limite do evento. Verifique parâmetro 'minTimeBetweenSessions'")
11"Skipping event because 'isStopTracking' enabled" ("Ignorando evento porque 'IsStopTracking' está ativado")
40Network error: Error description comes from Android (Erro de rede: descrição do erro vem do Android)
41"No dev key" ("Sem chave do desenvolvedor")
50"Falha no código de status" + código de resposta real do servidor