Intégration
Vous pouvez initialiser le plugin en utilisant le prefab AppsFlyerObject ou l'intégrer manuellement.
- Utiliser le prefab AppsFlyerObject.
- Intégration manuelle
- Collecter l'IDFA avec ATTrackingManager
- Send consent for DMA compliance
- Envoyer des postbacks SKAN à AppsFlyer
- Initialisation de MacOS
- Ports d'écoute de requêtes (optionnel)
Utiliser le prefab AppsFlyerObject.
- Allez dans Éléments > AppsFlyer et faites glisser AppsFlyerObject.prefab dans votre scène.
- Mettez à jour les champs suivants :
Réglage | Description |
---|---|
Clé dev | La clé dev AppsFlyer, qui se trouve dans le tableau de bord AppsFlyer. |
App ID | Votre ID d'app iTunes (si votre app n'est pas conçue pour iOS, laissez le champ vide) |
Obtenir les données de conversion | Réglez ce paramètre sur true si votre application utilise AppsFlyer pour le deep linking. |
isDebug | Réglez ce paramètre sur true pour afficher les journaux de débogage (pour le développement uniquement !) |
- Mettez à jour le code dans Éléments >AppsFlyer > AppsFlyerObjectScript.cs pour se conformer aux autres API.
Intégration manuelle
Créez un game object et ajoutez le code init suivant :
using AppsFlyerSDK;
public class AppsFlyerObjectScript : MonoBehaviour
{
void Start()
{
AppsFlyer.initSDK("devkey", "appID");
AppsFlyer.startSDK();
}
}
Remarque :
- Remarque : veillez à ne pas appeler la destruction du game object.
- Use
DontDestroyOnLoad
pour conserver l'objet lors du transfert d'une nouvelle scène.
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
before calling startSDK
.
Collecter l'IDFA avec ATTrackingManager
-
Ajoutez
AppTrackingTransparency
à votre projet xcode. -
Dans la section
Info.plist
:- Ajoutez une entrée à la liste : cliquez sur le + à côté de
Information Property List
. - Faites défiler l'écran et sélectionnez
Privacy - Tracking Usage Description
. - Ajoutez comme valeur la formulation que vous souhaitez présenter à l'utilisateur pour lui demander l'autorisation de collecter l'IDFA.
- Ajoutez une entrée à la liste : cliquez sur le + à côté de
-
Appelez
waitForATTUserAuthorizationWithTimeoutInterval
de l'api avantstartSDK()
#if UNITY_IOS && !UNITY_EDITOR AppsFlyer.waitForATTUserAuthorizationWithTimeoutInterval(60); #endif
-
Request 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(); } /* ... */
Customizing the ATT consent dialog
La boîte de dialogue de consentement ATT peut être personnalisée en modifiant dans votre projet Xcode info.plist
:
Pour des instructions détaillées, voir la documentation d'Apple.
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
-
Initialize the SDK.
-
Call enableTCFDataCollection(true) api before startSDK() to instruct the SDK to collect the TCF data from the device.
-
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.
-
Get confirmation from the CMP that the user has made their consent decision and the data is available.
-
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
- Initialize the SDK.
- Determine whether the GDPR applies or not to the user.
When GDPR applies to the user
-
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. -
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.
-
Call setConsentData()with the AppsFlyerConsent object.
-
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
-
Create an AppsFlyerConsent object using the ForNonGDPRUser() initializer. This initializer doesn’t accept any parameters.
-
Pass the empty AppsFlyerConsent object to setConsentData().
-
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:
- Enable the SDK debug mode.
- Search for consent_data in the log of the outgoing request.
for more information visit iOS
Android
Envoyer des postbacks SKAN à AppsFlyer
Pour enregistrer le point de terminaison AppsFlyer, vous devez ajouter NSAdvertisingAttributionReportEndpoint
à votre info.plist puis lui donner la valeur suivante https://appsflyer-skadnetwork.com/
.
Les infos sur la mise à jour du fichier info.plist se trouvent ici.
Initialisation de MacOS
- Utilisez le prefab
AppsFlyerObject
- Ajoutez votre ID d'app MacOS
- Faites un build pour les plateformes
PC, Mac & Linux Standelone
et choisissezMacOS
comme plateforme cible.
Ports d'écoute de requêtes (optionnel)
- Joignez le script 'AppsFlyer.cs' au game object avec le code d'initialisation AppsFlyer. (AppsFlyerObject, ect)
- Ajoutez le code suivant devant startSDK()
Exemple de réponse aux sessions :
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);
}
Exemple de réponse 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();
}
statusCode | errorDescription |
---|---|
200 | null |
10 | "Event timeout. (« Délai de l'événement ») Vérifiez 'minTimeBetweenSessions' param" |
11 | "Skipping event because 'isStopTracking' enabled" (« Sauter l'événement car isStopTracking est activé ») |
40 | Erreur réseau : la description de l'erreur provient d'Android |
41 | "No dev key" (« Pas de clé de développement ») |
50 | « Status code failure » + code correspondant à la réponse du serveur |
Mis(e) à jour il y a 10 mois