Open kekchpek opened 2 months ago
Hi @kekchpek,
This should work fine in case you have added Adjust.prefab
to your scene. However, if you are using some game object named differently (not Adjust
) where you are loading Adjust.cs
script, then you should pass that GO name as a 2nd (optional) parameter of the setAttributionChangedDelegate
method. If that's the case, give this a shot:
adjustConfig.setAttributionChangedDelegate(OnConversationReceived, "MyGameObjectName");
Looking forward to hearing back from you if this helped.
Firstly, I don't use GameObject at all. This code is put in regular C# class. Your suggestion doesn't seem platform dependent. Why don't I have issues on Android in this case if problem connected with Unity-level GameObject?
Secondly this doesn't explain why Adjust.getAttribution()
returns null. It doesn't connected with GameObjects at all.
Anyway I'll try to make a GameObject and follow your advice, thank you.
Issue in Android doesn't exist due to the nature of implementation of communication between C# and native Android (Java) layer. In iOS, it's working in a bit different way where when the message from native is supposed to be sent to Unity layer, it works practically via (for sake of easier explanation) some form of reflection. In particular, this line: https://github.com/adjust/unity_sdk/blob/v4.38.1/Assets/Adjust/iOS/AdjustUnityDelegate.mm#L113. This is where attribution obtained natively is attempted to be sent to C# layer. UnitySendMessage
is trying to send message to game object (first parameter) which is having method with specified name (second parameter) implemented. This is implemented inside of the Adjust.cs
script (https://github.com/adjust/unity_sdk/blob/v4.38.1/Assets/Adjust/Unity/Adjust.cs#L986) which normally gets loaded inside of the Adjust.prefab
in which case default GO name being set to "Adjust" makes things work. However, if you decide to load Adjust script elsewhere, then you should state the other name.
When it comes to Adjust.getAttribution()
returning null, you're right, this has nothing to do with the GO since it's a sync mechanism for which we don't need to use UnitySendMessage
logic under the hood. Attribution information is something that is generated on the backend and SDK initially doesn't contain this information. For SDK to obtain attribution, upon first launch of the SDK ever, SDK needs to track install session first (initial request sent to backend), wait for a bit (around 2 seconds) and then ask for attribution information from the backend which, if the attribution is finalized, sends it back to SDK. In this moment, attribution callback should get triggered and from that moment on, Adjust.getAttribution()
method should be returning actual attribution value and not null.
If the SDK has obtained attribution, attribution getter shouldn't be returning null even if attribution callback has not been triggered due to some potential integration issue we're discussing about. So that part is weird. In order to understand what's happening, it would be helpful to see what is SDK natively logging when you run the app from the Xcode. If you don't make it work and would like us to check what's up, it would be good to get logs after run like this:
[Adjust]
).Also, if you are up for, you can upgrade Adjust SDK to SDK v5.0.1 where we have replaced UnitySendMessage
with MonoPInvokeCallback
logic which should eliminate this GO SDK v4 concern from above. And also, getAttribution()
is async getter in v5.0.1 so that you don't need to think about timing of this call, but invoke it and get it triggered as soon as SDK obtains the attribution.
I use the code above to initialize adjust sdk and handle attribution data. It works well on Android devices. But I have problems on iOS. The callback I set with
setAttributionChangedDelegate
isn't called andAdjust.getAttribution()
returns null. What can be a reason? Maybe I have to add something inplist
or configureAdjustConfig
in some other way?