-
Notifications
You must be signed in to change notification settings - Fork 308
Description
Hi everyone π
I want to request an API improvement when resolving shortened deep links.
Right now, we need to call Adjust.processAndResolveDeeplink(β¦) to do a network call that retrieves the deep link. The problem is that this call does not return any error when the user does not have Internet, when the provided AdjustDeeplink is not valid, the callback is null, or any other possible error.
This makes it quite difficult to understand if something went wrong and provide a good UX.
It would be great to have a version of processAndResolveDeeplink that can throw an exception when something goes wrong, so we can handle the different errors.
It would even be better to provide support for Kotlinx Coroutines to make that method suspend.
My use case is:
- I want to resolve the shortened link from a splash screen
- I don't want to let the user enter the app until the link is resolved.
- In case the link resolution fails, either because the user does not have Internet or for any other reason, I would like to let the user retry the link resolution until he has Internet.
- Ideally, if the error is non-retriable, for example, the
AdjustDeeplinkis not valid, I may let the user continue to the app, as theprocessAndResolveDeeplinkcall will never succeed.
To illustrate a bit better my current solution, here's a short snippet on how I use a timeout to prevent waiting too long when the user does not have Internet, so I can show them a retry button.
The problem with this solution is that it works well when the user does not have Internet, but not when the provided link is not valid, as the link resolution will never succeed, thus the callback will never be called, and the user may get stuck retrying the action indefinitely without success.
β¦
try {
val deepLink = withContext(ioDispatcher) {
withTimeout(10.seconds) {
suspendCancellableCoroutine { continuation ->
processAndResolveDeeplink(AdjustDeeplink(deepLink), context) { resolvedLink ->
continuation.resume(resolvedLink)
}
}
}
}
// Navigate to the deep link destination
} catch(β¦) {
// Explain what was wrong and let the user retry the link resolution
}I guess the errors are not exposed from processAndResolveDeeplink because the intention is to use that method as a global handler in the app, but not as a "synchronous" call to retrieve the resolved link in place.
It would be great to have a method that can resolve a deep link or return/throw an error when something goes wrong.