adjust / unity_sdk

This is the Unity SDK of
http://www.adjust.com
MIT License
149 stars 70 forks source link

I can't access to "Ad-ID" in the first session #274

Open Mustafax06 opened 11 months ago

Mustafax06 commented 11 months ago

I need Ad-ID within 1 minute of the first session. But I could never get the ID in the first session, in the second session, it retrieves immediately. Can I get it in the first second? Here's my code (I'm initializing the SDK automatically, not manually);

private IEnumerator CheckAndSetAdID() { while (string.IsNullOrEmpty(Adjust.getAdid())) { yield return new WaitForSeconds(0.5f); } _purchases.SetAdjustID(Adjust.getAdid()); Debug.Log("Adjust ID has been set: " + Adjust.getAdid()); }

I need this ID because most of our users make their first purchases within the first minute of the first session. And RevenueCat receives the purchase and logs it to Adjust. So I need the Ad-ID ASAP in the first session but I could never get it.

Edit: sorry for the badly formatted code, I couldn't arrange it, sorry

uerceg commented 10 months ago

Hi @Mustafax06,

adid is a backend-side generated identifier which Adjust SDK gets only after it communicates for the first time ever with our backend and then gets this back in the answer we receive from the backend. When Adjust SDK is launched in the app for the first time ever, it sends a package we call a session to the backend. After backend responds to it, this is the first moment in which SDK gets the adid value, caches it locally and as of that moment on, provides it back if Adjust.getAdid() getter is called. We still do have a (nowadays) misfortunate implementation of this getter which is synchronous and will provide you with null back until SDK obtains the adid value, but this will change with the upcoming major SDK v5 release.

If one would want to capture the moment in which SDK is getting in possession of adid for the first time ever without the need to loop the "poll the getter -> get null -> retry" sequence, way to do that would be to implement session tracking callbacks. These callbacks would get pinged when session sending attempt succeeds / fails and if you'd check AdjustSessionSuccess and AdjustSessionFailure instances, they should contain the field which contains the adid value.

So I'd advise you maybe to give these callbacks a shot and double check if that works for your use case. Feel free to ping in case you have any further questions.

Nawfel-bel commented 6 months ago

Hello there @uerceg, Can you please make sure that the SessionSuccessCallback and the SessionFailureCallback are working? because they dont seem to be invoked at all despite setting the delegates, just a simple log statement isnt even excecuted. which makes it difficult to understand when the adId is being cached