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

Async Adid getter never calling the ADJAdidGetterBlock callback #740

Open
alessioborraccino opened this issue Nov 6, 2024 · 11 comments
Open

Comments

@alessioborraccino
Copy link

Hi,

While attempting to migrate to adjust 5 from 4, i encountered an issue:
These methods became asynchronous:

open class func adid(completionHandler completion: @escaping ADJAdidGetterBlock)
open class func adid() async -> String?

Since we need to get the adid, we try to fetch it and store it , between other times, also at a certain time after the initialisation of the SDK.
Unfortunately, after the session and attribution are assigned, if ADID is still nil, trying to access it with the new asynchronous functions results in a hang forever, because the completion callback never gets called.

Could you please double check this, and help me out either with a fix or a work around solution?

Alessio Borraccino from Autoscout24

@uerceg
Copy link
Contributor

uerceg commented Nov 8, 2024

Hey @alessioborraccino,

Yes, adid getter method is now asynchronous. Quick explanation behind why is that obtaining adid by the SDK is something that's dependent on SDK managing to make initial request to our backend successfully and get response to it (adid is part of that response since it's a backend generated identifier). v4 had this method as synchronous and what that caused was that invoking it in the wrong time (by the time SDK still doesn't have it) would result in that method returning nil. This was confusing many clients and they were effectively forced to come with some retry workarounds to be able to invoke the getter in right moment. Those complains and requests to address that state of things is why this getter is async in v5.

As explained above, for adid to be present on the SDK side of things, SDK needs to be able to communicate with the backend to get it. After SDK has obtained it once, it's persisted locally and any subsequent invocation of the API should return the identifier immediately back to you. So in theory, the only "gap" where one should see delay in adid being delivered to the completion handler is if the getter would be invoked before SDK has obtained the adid.

You not seeing adid completion handler being triggered at all indeed sounds odd. Would you be able to do one test run with SDK set to sandbox mode and log level set to verbose (+ if you can add some log print of yours when is that you're invoking the getter), omit any sensitive data from logs and send them over to us to see what is that might be happening that's causing adid not to be sent back?

@alessioborraccino
Copy link
Author

Using:

XCode: 16.0
Device: iPhone SE (3rd Generation) simulator (debugging with XCode)
iOS: 18.0

Here is the log at first start of the app where it hangs:

[Adjust]w: SANDBOX: Adjust is running in Sandbox mode. Use this setting for testing. Don't forget to set the environment to production before publishing
[Adjust]d: Delegate implements adjustDeferredDeeplinkReceived:
[Adjust]i: ATT consent waiting interval has been configured to 15
[Adjust]d: Adjust directory not present and will be created
[Adjust]d: File AdjustIoAttribution not found in "Application Support/Adjust" folder
[Adjust]d: File AdjustIoAttribution not found in Documents folder
[Adjust]d: File AdjustIoActivityState not found in "Application Support/Adjust" folder
[Adjust]d: File AdjustIoActivityState not found in Documents folder
[Adjust]d: File AdjustSessionCallbackParameters not found in "Application Support/Adjust" folder
[Adjust]d: File AdjustSessionCallbackParameters not found in Documents folder
[Adjust]d: File AdjustSessionPartnerParameters not found in "Application Support/Adjust" folder
[Adjust]d: File AdjustSessionPartnerParameters not found in Documents folder
[Adjust]i: Send in background configured
[Adjust]d: File AdjustIoPackageQueue not found in "Application Support/Adjust" folder
[Adjust]d: File AdjustIoPackageQueue not found in Documents folder
[Adjust]d: LinkMe general board not found
[Adjust]d: Added package 1 (session)
[Adjust]e: Error while retrieving AdServices attribution token: Error Domain=com.apple.ap.adservices.attributionError Code=3 "Attribution services are only available on iOS and iPadOS." UserInfo={NSLocalizedDescription=Attribution services are only available on iOS and iPadOS.}
[Adjust]w: Unable to read AdServices details
[Adjust]d: Package handler wrote 1 packages
[Adjust]d: Wrote Activity state: ec:0 sc:1 ssc:1 ask:0 sl:0.0 ts:0.0 la:1731071552.4 pt:(null) gdprf:0 dtpsc:0 att:0
[Adjust]d: Package handler is paused
[Adjust]d: Start sdk, since the app is already in the foreground
[Adjust]d: Added sdk_click 1
[Adjust]d: Wrote Activity state: ec:0 sc:1 ssc:1 ask:0 sl:0.0 ts:0.0 la:1731071552.4 pt:(null) gdprf:0 dtpsc:0 att:0
[Adjust]w: ATT status waiting timeout elapsed without receiving any consent status update
[Adjust]d: Wrote Activity state: ec:0 sc:1 ssc:1 ask:0 sl:0.0 ts:0.0 la:1731071552.4 pt:(null) gdprf:0 dtpsc:0 att:0
[Adjust]e: Error while retrieving AdServices attribution token: Error Domain=com.apple.ap.adservices.attributionError Code=3 "Attribution services are only available on iOS and iPadOS." UserInfo={NSLocalizedDescription=Attribution services are only available on iOS and iPadOS.}
[Adjust]d: Authorization header content: Signature signature="---",adj_signing_id="1100001",algorithm="adj5",headers_id="5",native_version="3.32.0"
[Adjust]d: Authorization header content: Signature signature="---",adj_signing_id="1100001",algorithm="adj5",headers_id="5",native_version="3.32.0"
[Adjust]d: Request succeeded with current URL strategy
[Adjust]d: Got click JSON response with message: SDK click failed (failed to handle sdk click) (app_token:--- adid:1a6d745ed81f2eae836dfecb86b05e06)
[Adjust]i: Received Apple Ads click response
[Adjust]d: Request succeeded with current URL strategy
[Adjust]d: Got JSON response with message: Session failed (request check interval failed (Ignoring too frequent session. Last session: 2024-11-08T13:10:16, this session: 2024-11-08T13:12:33, interval: 2m17s, min interval: 20m)) (app_token:rxskvz5da9f3 adid:1a6d745ed81f2eae836dfecb86b05e06)
[Adjust]d: Package handler wrote 0 packages
[Adjust]d: Wrote Activity state: ec:0 sc:1 ssc:1 ask:0 sl:0.0 ts:0.0 la:1731071552.4 pt:(null) gdprf:0 dtpsc:0 att:0
[Adjust]d: Wrote Activity state: ec:0 sc:1 ssc:1 ask:0 sl:0.0 ts:0.0 la:1731071552.4 pt:(null) gdprf:0 dtpsc:0 att:0
[Adjust]d: Authorization header content: Signature signature="---",adj_signing_id="1100001",algorithm="adj5",headers_id="5",native_version="3.32.0"
[Adjust]d: Request succeeded with current URL strategy
[Adjust]d: Got attribution JSON response with message: Attribution request failed (invalid signature) (app_token:rxskvz5da9f3 adid:1a6d745ed81f2eae836dfecb86b05e06)
[Adjust]d: Wrote Activity state: ec:0 sc:1 ssc:1 ask:1 sl:0.0 ts:0.0 la:1731071552.4 pt:(null) gdprf:0 dtpsc:0 att:0

Then it hanges here forever

@uerceg
Copy link
Contributor

uerceg commented Nov 8, 2024

Can you try to:

  1. Get the adid from the logs and forget your device with it from testing console for your app token
  2. Retry the test

?

@saadaamir
Copy link

I am having the same issue

@uerceg
Copy link
Contributor

uerceg commented Nov 9, 2024

Hey @saadaamir,

Did you try the suggested steps? If yes, would it be possible to get the SDK verbose logs from the test run (and of course, feel free to omit any sensitive data from there)?

@uerceg uerceg closed this as completed Nov 9, 2024
@uerceg uerceg reopened this Nov 9, 2024
@saadaamir
Copy link

@uerceg
I resolved the issue by changing my implementation from SPM to Pod. With SPM integration AdjustConfig delegate methods were also not being called along with ADID callback. IDFA callback would return the correct value though.

On changing the implementation to Pod everything started to work as expected.

Hope this helps! @alessioborraccino

@uerceg
Copy link
Contributor

uerceg commented Nov 10, 2024

@saadaamir Thank you for letting us know, and that's extremely odd what you've faced (that this works for you if you use CocoaPods and it doesn't work with SPM). It really shouldn't be like that (it should work in the same way both ways). We will take a look at this claim on our end to see if there's any inconsistency between the two ways of integrating the SDK.

@alessioborraccino
Copy link
Author

@saadaamir thanks for the tip, unfortunately going back to pods is not an option for us.
@uerceg i followed these steps:

  1. Forgot device from Testing console
  2. Deleted app from simulator
  3. Reinstalled and Started the app from Xcode and no hangs
  4. Killed the app, restarted again from XCode, no hangs
  5. Uninstalled the app from simulator
  6. Reinstalled and started via debug again, but now it hangs again

Once in this state it never moves forward anymore.

@uerceg
Copy link
Contributor

uerceg commented Nov 11, 2024

Hey @alessioborraccino,

Thanks for getting back to us. Reason why this is happening is following:

  1. Normally when SDK tracks installs or sessions for your users, those session requests are succeeding. When this happens, backend responds to us how session tracking went well and as part of the response JSON it sends us (among other things) adid: value in the root of that response. This is where our SDK is picking up the value from (to store it and ping adid callbacks with).
  2. However, when session gets rejected by our backend, adid is not the top level parameter in the JSON (but instead, part of the message field). In this case, SDK will not pick up this value.

What you are seeing in your steps 5-6 is the bullet point 2 from above. Once you reinstall app on your test device, you're wiping our internally stored information which makes SDK aware that it has tracked session before. So upon relaunching the app, SDK will immediately try to send session request first. However, having in mind that your test device has successfully sent session request seconds/minutes ago, our backend will reject it as being too frequent, effectively causing scenario from bullet point 2.

I would say that this should be pretty edge case in production (effectively happening only to your users who have opened their apps and then after that managed to reinstall your app and open it in less than 30 minutes). However, we'll check into adding this change so that adid ends up being top level parameter in response when session request gets rejected as well to have this case covered as well.

Hopefully this clears things up a bit. In case you have additional questions, feel free to ping.

@alessioborraccino
Copy link
Author

alessioborraccino commented Nov 11, 2024

@uerceg ,

thanks for looking into it.

I am not sure i understand why top level parameters for the json are the issue here, but it doesn't matter too much to us, if you understand the issue it's already a good step forward.

It's obvious that we can't update the sdk in the app until this is resolved, for 2 reasons:

  1. it's anyways risking hangs also in production, even if for just this edge case;
  2. it would anyways block our debugging process everytime we want to reinstall the app on the simulator.

Considering this, please let me know when it's solved, as we wanted to go forward with testing the update with some weeks before xmas, to make sure everything works correctly.

@uerceg
Copy link
Contributor

uerceg commented Nov 11, 2024

Sure thing, we'll keep you posted. 👌

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

3 participants