Branch.io Cordova SDK not reinitialising when app is resumed

409 views Asked by At

The new Branch.io Cordova SDK the documentation makes it clear that the SDK automatically closes the current branch session when the app is paused or backgrounded, but it does not seem to automatically init a new session when the app is resumed from memory.

If the app is resumed after it's been killed from memory, the branch.init method in my app's onReady code does execute - this is only an issue when resuming a paused app.

Do I need to trigger another init manually? Any insight would be great!

1

There are 1 answers

1
Scott Hasbrouck On BEST ANSWER

I'm Scott with Branch, and the lead architect for the Web SDK (which includes the Cordova SDK). Yes, you're correct that the SDK automatically closes the Branch session whenever the app is paused. However, it does not (yet) automatically initialize a new session when it is resumed. Which means, you do need to trigger another init manually everytime the resume event fires.

Bind this event as you would any other startup event listener:

...
onResume = function() {
    branch.init('KEY');
};

...

bindEvents: function() {
   document.addEventListener('resume', this.onResume, false);
}
...

We've had a number of requests to automatically call init on resume, and will be releasing this shortly! I'll make a note to update this response once we've done so.