android-branch-deep-linking-attribution icon indicating copy to clipboard operation
android-branch-deep-linking-attribution copied to clipboard

Init session callback is never called in 4.2.0

Open llDavidll opened this issue 5 years ago • 8 comments

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 ServerRequestRegisterInstall object is created automatically when the activity is started (with a null callback)
  • A second ServerRequestRegisterInstall object is created when I call initSession, 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 ServerRequestRegisterInstall object is created automatically when the activity is resumed (with a null callback)
  • A second ServerRequestRegisterInstall object is created when I call initSession, 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 avatar Nov 27 '19 15:11 llDavidll

@llDavidll do you call initSession from onStart?

bklastaitis-branch avatar Nov 27 '19 19:11 bklastaitis-branch

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.

llDavidll avatar Nov 28 '19 10:11 llDavidll

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.

Danyaga avatar Nov 28 '19 11:11 Danyaga

@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/

bklastaitis-branch avatar Nov 30 '19 06:11 bklastaitis-branch

@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 avatar Nov 30 '19 06:11 bklastaitis-branch

@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.

Danyaga avatar Nov 30 '19 12:11 Danyaga

I am facing the same issue now using version 4.1.0 again

iamatulkumar avatar Dec 14 '19 05:12 iamatulkumar

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?

jgarin-earnin avatar Apr 07 '20 20:04 jgarin-earnin