Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The consent dialog does not appear even if the first launch of the app. #5

Open
ctykaya opened this issue Oct 15, 2024 · 0 comments
Open

Comments

@ctykaya
Copy link

ctykaya commented Oct 15, 2024

We are using Unity SDK i cannot find the related repository so sorry for posting here.
Choice SDK Version is 2.0.0

Below is the implementation of Choice SDK class.

using System;
using System.Collections;
using UnityEngine;


public class InMobiController : MonoBehaviour
{
    public GameEvent OnPlayerConsent;
    public GameEvent OnCMPDidErrorEvent;
    private const string  pCode = "mycodewithout p- ";

    public static InMobiController instance = null;
    private bool isConsent = false;

  
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
            SubEvents();
            ChoiceCMP.ChoiceLogLevel = ChoiceCMP.LogLevel.Debug;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(this);
        }
    }

    private void Start()
    {
        StartCoroutine(DelayedStartChoice());
    }

    private IEnumerator DelayedStartChoice()
    {
        yield return new WaitForSeconds(1f);
        Debug.Log("Is ChoiceCMP ready to start? Logging SDK state before StartChoice");
        ChoiceCMP.StartChoice(pCode);
        Debug.Log($"After Start Choice P-Code  {pCode}");
    }

    public void ForceDisplayUI()
    {
        ChoiceCMP.ForceDisplayUI();
    }
    public void ShowCCPA()
    {
        ChoiceCMP.ShowCCPA();
    }

    private void SubEvents() {
        ChoiceCMPManager.CMPDidLoadEvent += delegate (PingResult pingResult)
        {
            // Fired when the SDK has finished loading
            Debug.Log($"CMPDidLoadEvent");
        };

        ChoiceCMPManager.CMPDidErrorEvent += delegate (string error)
        {
            // Fired when SDK fails to load
            Debug.Log($"CMPDidErrorEvent {error}");
            OnCMPDidErrorEvent.Raise(this,error);
            StartCoroutine(DelayedStartChoice());
        };

        ChoiceCMPManager.CMPDidShowEvent += delegate (PingResult pingResult)
        {
            // Fired when popup is shown
            Debug.Log("CMPDidShowEvent");
        };

        ChoiceCMPManager.CMPDidReceiveAdditionalConsentEvent += delegate (ACData acData)
        {
            // Fired when on receiving the Additional Consent
            Debug.Log($"CMPDidReceiveAdditionalConsentEvent {acData.acString}");
            
            if (!isConsent) {
                isConsent = true;
                OnPlayerConsent.Raise(this, null);
            }
            
        };

        ChoiceCMPManager.CMPDidReceiveCCPAConsentEvent += delegate (string ccpaConsent)
        {
            // Fired when on receiving the CCPA Consent
            Debug.Log($"CMPDidReceiveCCPAConsentEvent {ccpaConsent}");
            
            if (!isConsent)
            {
                isConsent = true;
                OnPlayerConsent.Raise(this, null);
            }
            //OnPlayerConsent.Raise(this, null);
        };
        ChoiceCMPManager.CMPDidShowEvent += delegate (PingResult result) {
            Debug.Log($"Api Version: {result.apiVersion}\n Loaded:{result.cmpLoaded}\n Status: {result.cmpStatus}\n Display Status: {result.displayStatus}\n ToString:{result.ToString()}");

	    };
        ChoiceCMPManager.CMPUserDidMoveToOtherState += delegate {

            Debug.Log("User Did Move To Other State");
    	};
 
        ChoiceCMPManager.CMPDidReceiveNonIABVendorConsentEvent += delegate (NonIABData nonIABData)
        {
            // Fired when on receiving the NON IAB Vendor Consent
            if (!isConsent)
            {
                isConsent = true;
                OnPlayerConsent.Raise(this, null);
            }
            //OnPlayerConsent.Raise(this, null);
            Debug.Log($"CMPDidReceiveNonIABVendorConsentEvent {nonIABData.gdprApplies}");
        };

    }

    
}

Below are the Unity Logs from Choice SDK

2024/10/15 11:41:58.381 23366 23448 Info Unity [InMobiCMP-Unity] [StartChoice] Choice initialization started
2024/10/15 11:41:58.390 23366 23448 Info Unity [InMobiCMP-Unity] [StartChoice] Choice initialized successfully.

I added a button for testing purposes to trigger the ForceDisplayUI() method. When i clicked it. The below errror logged in the console.

2024/10/15 11:46:20.018 23366 23448 Info Unity [InMobiCMP-Unity] [EmitCMPDidErrorEvent] Choice failed to load, error: SDK must be initialized first by calling startChoice method

Can anyone help. We cannot show the consent dialog.

And also the .gradle file outliened as the documentation

apply plugin: 'com.android.library'
**APPLY_PLUGINS**

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0"



    implementation 'androidx.appcompat:appcompat:1.4.1' 
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3' 
    implementation 'androidx.recyclerview:recyclerview:1.2.1' 
    implementation 'androidx.cardview:cardview:1.0.0' 
    implementation 'com.google.code.gson:gson:2.10.1'
    implementation 'com.google.android.material:material:1.3.0' 
    // KTX
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" 
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1"


// Android Resolver Dependencies Start
    implementation 'androidx.activity:activity:1.6.0' // Assets/GooglePlayPlugins/com.google.play.appupdate/Editor/Dependencies.xml:4
    implementation 'com.android.support:customtabs:28.+' // Assets/MaxSdk/Mediation/InMobi/Editor/Dependencies.xml:7
    implementation 'com.android.support:recyclerview-v7:28.+' // Assets/MaxSdk/Mediation/InMobi/Editor/Dependencies.xml:6
    implementation 'com.applovin.mediation:fyber-adapter:8.3.1.1' // Assets/MaxSdk/Mediation/Fyber/Editor/Dependencies.xml:4
    implementation 'com.applovin.mediation:inmobi-adapter:10.7.7.2' // Assets/MaxSdk/Mediation/InMobi/Editor/Dependencies.xml:4
    implementation 'com.applovin.mediation:vungle-adapter:7.4.1.2' // Assets/MaxSdk/Mediation/Vungle/Editor/Dependencies.xml:4
    implementation 'com.applovin:applovin-sdk:13.0.0' // Assets/MaxSdk/AppLovin/Editor/Dependencies.xml:4
    implementation 'com.google.android.gms:play-services-auth:16+' // Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml:10
    implementation 'com.google.android.gms:play-services-base:18.5.0' // Assets/Firebase/Editor/AppDependencies.xml:17
    implementation 'com.google.android.play:app-update:2.1.0' // Assets/GooglePlayPlugins/com.google.play.appupdate/Editor/Dependencies.xml:3
    implementation 'com.google.android.play:core-common:2.0.0' // Assets/GooglePlayPlugins/com.google.play.core/Editor/Dependencies.xml:3
    implementation 'com.google.android.play:review:2.0.0' // Assets/GooglePlayPlugins/com.google.play.review/Editor/Dependencies.xml:3
    implementation 'com.google.firebase:firebase-analytics:22.1.0' // Assets/Firebase/Editor/MessagingDependencies.xml:15
    implementation 'com.google.firebase:firebase-analytics-unity:12.3.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18
    implementation 'com.google.firebase:firebase-app-unity:12.3.0' // Assets/Firebase/Editor/AppDependencies.xml:22
    implementation 'com.google.firebase:firebase-auth:23.0.0' // Assets/Firebase/Editor/AuthDependencies.xml:13
    implementation 'com.google.firebase:firebase-auth-unity:12.3.0' // Assets/Firebase/Editor/AuthDependencies.xml:20
    implementation 'com.google.firebase:firebase-common:21.0.0' // Assets/Firebase/Editor/AppDependencies.xml:13
    implementation 'com.google.firebase:firebase-crashlytics-ndk:19.1.0' // Assets/Firebase/Editor/CrashlyticsDependencies.xml:13
    implementation 'com.google.firebase:firebase-crashlytics-unity:12.3.0' // Assets/Firebase/Editor/CrashlyticsDependencies.xml:20
    implementation 'com.google.firebase:firebase-firestore:25.1.0' // Assets/Firebase/Editor/FirestoreDependencies.xml:13
    implementation 'com.google.firebase:firebase-firestore-unity:12.3.0' // Assets/Firebase/Editor/FirestoreDependencies.xml:20
    implementation 'com.google.firebase:firebase-iid:21.1.0' // Assets/Firebase/Editor/MessagingDependencies.xml:17
    implementation 'com.google.firebase:firebase-messaging:24.0.1' // Assets/Firebase/Editor/MessagingDependencies.xml:13
    implementation 'com.google.firebase:firebase-messaging-unity:12.3.0' // Assets/Firebase/Editor/MessagingDependencies.xml:24
    implementation 'com.google.flatbuffers:flatbuffers-java:1.12.0' // Assets/Firebase/Editor/MessagingDependencies.xml:19
    implementation 'com.google.signin:google-signin-support:1.0.4' // Assets/GoogleSignIn/Editor/GoogleSignInSupportDependencies.xml:9
    implementation 'com.squareup.picasso:picasso:2.71828' // Assets/MaxSdk/Mediation/InMobi/Editor/Dependencies.xml:5
    // implementation 'com.google.android.material:material:1.12.0' // Add this line
    


// Android Resolver Dependencies End
**DEPS**}

// Android Resolver Exclusions Start
android {
  packagingOptions {
      exclude ('/lib/armeabi/*' + '*')
      exclude ('/lib/mips/*' + '*')
      exclude ('/lib/mips64/*' + '*')
  }
}
// Android Resolver Exclusions End
android {
    namespace "com.unity3d.player"
    ndkPath "**NDKPATH**"
    compileSdkVersion **APIVERSION**
    buildToolsVersion '**BUILDTOOLS**'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }

    defaultConfig {
        minSdkVersion **MINSDKVERSION**
        targetSdkVersion **TARGETSDKVERSION**
        ndk {
            abiFilters **ABIFILTERS**
        }
        versionCode **VERSIONCODE**
        versionName '**VERSIONNAME**'
        consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
    }

    lintOptions {
        abortOnError false
    }

    aaptOptions {
        noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
    }**PACKAGING_OPTIONS**
}
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**

@ctykaya ctykaya changed the title The consent dialog does not appear event if the first launch of the app. The consent dialog does not appear even if the first launch of the app. Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant