Unity
Notre CMP est disponible pour Unity sous forme d'un Package Unity contenant les plugins pour Android, iOS et tvOS. Le package se trouve à l'adresse ci-dessous:
Le package supporte la version Unity minimum 2021.3.16f1 LTS.
Exécution simple
Cet exemple est pris directement de l'exemple de code ci-dessous.
Exemple Runner
Voici l'exemple de projet Runner Unity dans lequel nous avons intégré notre solution. Sample
Exemple de développeur
Voici un exemple de projet Unity dans lequel nous avons intégré notre solution, vous permettant d'interagir directement avec elle depuis l'écran principal. Exemple
Ajouter le package à votre projet Unity
Depuis le menu window, ouvrez le Package Manager
Sur la fenêtre du Package Manager, séléctionnez le bouton + en haut à gauche. Dans le menu déroulant séléctionnez Add package from git URL.
Dans le champs texte, rentrez l'url git du package https://gitlab.datalf.chat/customers/appconsent-unity.git et cliquez sur Add.
Le package est désormais ajouté à votre projet.
Recommendation Android
Le plugin vous donne la possibilité de définir un callback de succès ou d'erreur avant l'initialisation de la CMP qui vous permettra de Logger et/ou d'utiliser la CMP quand celle-ci est complètement initialisé (asynchrone).
Voici un exemple de fonctionnement pour la CMP sur Android
using SFBX.AppConsent;
using UnityEngine;
using System.Collections;
public class AppConsentGUI : MonoBehaviour, ISDKCallbackListener, ISDKPresentNoticeListener
{
ACNotice bridge = null;
private bool isCmpInitialized = false;
int centerX = Screen.width / 2;
int buttonWidth = Screen.width / 2;
int buttonHeight = Screen.height / 14;
int buttonX;
GUIStyle labelStyle = new GUIStyle();
GUIStyle buttonStyle;
string status = "";
int logIndice = 0;
void Awake()
{
AndroidJNIHelper.debug = true;
// Only for Android - does not impact iOS !
ACNotice.SetNoticeCallback(this);
bridge = new ACNotice("18ecaea4-554a-4f74-9242-520fe62058a8");
UpdateStatus("bridge instanciated => " + bridge);
}
// Start is called before the first frame update
void Start()
{
labelStyle.alignment = TextAnchor.MiddleCenter;
labelStyle.normal.textColor = Color.white;
buttonX = centerX - ( buttonWidth / 2);
bridge.InitACNotice();
#if UNITY_IOS || UNITY_TVOS
// On iOS, there's no need for a callback, so you can directly change the boolean's state.
OnReadyOnSuccess();
#endif
}
// Update is called once per frame
void Update()
{
centerX = Screen.width / 2;
buttonWidth = Screen.width / 2;
buttonHeight = Screen.height / 14;
buttonX = centerX - ( buttonWidth / 2);
}
void OnGUI()
{
labelStyle.fontSize = 28;
labelStyle.wordWrap = true;
buttonStyle = new GUIStyle(GUI.skin.button);
buttonStyle.fontSize = 28;
GUI.Label(new Rect(buttonX, buttonHeight * 2, buttonWidth, buttonHeight), "SFBX AppConsent", labelStyle);
if (GUI.Button(new Rect(buttonX, buttonHeight * 4, buttonWidth, buttonHeight), "Display CMP", buttonStyle))
{
if(isCmpInitialized == true && bridge != null){
bridge.SetPresentNoticeListener(this);
bool isDisplayed = bridge.ShowNotice();
if(isDisplayed == true){
UpdateStatus("Notice displayed");
}else{
UpdateStatus("Notice not displayed, look at your consent or RGPD country.");
}
}else{
UpdateStatus("AppConsent not ready yet");
}
}
if (GUI.Button(new Rect(buttonX, buttonHeight * 6, buttonWidth, buttonHeight), "Settings", buttonStyle))
{
if(isCmpInitialized == true && bridge != null){
bridge.ShowSettings();
UpdateStatus("Settings displayed");
}else{
UpdateStatus("AppConsent not ready yet");
}
}
if (GUI.Button(new Rect(buttonX, buttonHeight * 8, buttonWidth, buttonHeight), "Check Consents", buttonStyle))
{
if(isCmpInitialized == true && bridge != null){
bool consent = bridge.ConsentGiven();
bool allConsentables = bridge.AllConsentablesAllowed();
bool gdpr = bridge.IsSubjectToGDPR();
bool acceptAll = bridge.UserAcceptAll();
bool extra = bridge.ExtraVendorAllowed("TobuM9Iw");
bool consentable = bridge.ConsentableAllowed(1,0);
UpdateStatus("consents: " + consent + allConsentables + gdpr + acceptAll + extra + consentable);
}else{
UpdateStatus("AppConsent not ready yet");
}
}
if (GUI.Button(new Rect(buttonX, buttonHeight * 10, buttonWidth, buttonHeight), "Reset Consents", buttonStyle))
{
if(isCmpInitialized == true && bridge != null){
bridge.ClearConsents();
UpdateStatus("Cleared consents");
}else{
UpdateStatus("AppConsent not ready yet");
}
}
GUI.Label(new Rect(0, buttonHeight * 12, Screen.width, buttonHeight), status, labelStyle);
}
public void OnReadyOnSuccess()
{
UpdateStatus("Appconsent onReadyOnSuccess");
isCmpInitialized = true;
Debug.Log("AppConsent is ready to be use !");
UpdateStatus("Setting listener + trying to show notice");
bridge.SetPresentNoticeListener(this);
bool isDisplayed = bridge.ShowNotice();
if(isDisplayed == true){
UpdateStatus("Notice displayed");
}else{
UpdateStatus("Notice not displayed, look at your consent or RGPD country.");
}
}
public void OnReadyOnError(AndroidJavaObject err)
{
isCmpInitialized = false;
Debug.LogError("Failed to start AppConsent");
}
public void OnConsentGiven()
{
Debug.Log("The user has given his consent");
UpdateStatus("Consent given !");
}
public void OnConsentGivenError(AndroidJavaObject err)
{
Debug.LogError("An error as occurred, please read Log.");
UpdateStatus("An error as occurred, please read Log.");
}
private void UpdateStatus(string log){
if(logIndice % 10 == 0){
status = logIndice++ + " - " + log;
}else{
status = status + "\n" + logIndice++ + " - " + log;
}
}
}
Documentation de l'API
Notre documentation d'api détaillée est ici.
FAQ
Toute notre FAQ ce trouve directement sur notre git, dans le README