android-branch-deep-linking-attribution
android-branch-deep-linking-attribution copied to clipboard
Init session callback is never called in 4.2.0
Hi,
I'm having an issue with version 4.2.0 and initSession. The same code is working with 4.1.2.
I'm calling initSession with a BranchReferralInitListener callback, and I wait for the result or the error in this callback. With 4.2.0, my callback is never called. Here is what I found after some debug :
4.1.2 (working):
- A first
ServerRequestRegisterInstallobject is created automatically when the activity is started (with a null callback) - A second
ServerRequestRegisterInstallobject is created when I callinitSession, this time with my callback.
The first ServerRequestRegisterInstall seems to be lost (onRequestSucceeded is never called), but the second one with my callback from initSession calls onRequestSucceeded which calls my callback : it works.
4.2.0 (not working)
- A first
ServerRequestRegisterInstallobject is created automatically when the activity is resumed (with a null callback) - A second
ServerRequestRegisterInstallobject is created when I callinitSession, this time with my callback.
This time the first ServerRequestRegisterInstall calls onRequestSucceeded, but this object is the one with the null callback so I do not receive anything. The second ServerRequestRegisterInstall seems to be lost, and this time it's the one with my callback so I never receive anything.
I don't know if it's relevant, but I noticed that the first ServerRequestRegisterInstall (with the null callback) is not created at the same time on the different versions :
- 4.1.2 creates it when the activity is started
- 4.2.0 creates it when the activity is resumed
@llDavidll do you call initSession from onStart?
No, I was calling it in onResume. Moving it to onStart seems to work. Is it a requirement ? I didn't find it in the readme.
As I told in the other issues, IMHO, it is not acceptable having a callback eventually called, in particular when you put an error as input of the call (that can also be a TimeoutException object or something). You should, at least, put a big warning in the documentation with the information that the callback may eventually called and so the developers can put a wrap outside your calls with a timeout that makes continue the code flow in their apps.
@llDavidll yes, as of v4.2.0, calling initSession in onStart is required. (If that never happens, we initialize the session in onResume on user's behalf though.) Here is the Android documentation describing the expected use of initSession: https://docs.branch.io/apps/android/
@Danyaga I've created a ticket to invoke the callback in this particular scenario (SDK-677). Were the other issues (related to callback not being invoked) addressed? If not, would you post links to them?
@bklastaitis-branch Thanks for the comment.
I was referring to this issue and this one, in particular, but, in general terms, I would like to trust you to call the given callback.
Another factual good example of callback not called is when the Activity finishes itself before the the call, this may happen when we have a "splash" activity that should be finished when the UX or our architecture require, and not by your SDK. Do you get my point? Would you rather to have a project to understand it better?
Again, otherwise, we have put more code (which is bad) to wrap your SDK that enforces the timeout in case of too long (or endless) waiting.
I am facing the same issue now using version 4.1.0 again
I'm facing this issue. The initSession method call is in onStart, the Activity stays on screen for minutes and the callback is never called when opening the app with a deeplink. However, if I open the app from the home screen the callback gets called every time.
Judging by the logs link parameters are retrieved successfully. Has this been fixed in any version?