2

I am using Branch.io deeplinking in my Android app, and for the most part, it works well under most scenarios. However, I have a scenario where I register a user (to my service); and in that flow, the user requests an SMS verification code, and thus has to leave the app (minimize) to read it, then re-enter the app (restore) to validate to code.

I had this behavior working perfectly before implementing branch.io, and the reason has to do with Branch.io requiring android:launchMode="singleTask" in the AndroidManifest.xml file (see here).

<activity
   android:name="com.yourapp.SplashActivity"
   android:label="@string/app_name"
   android:launchMode="singleTask"
   ...

When android:launchMode="singleTask" is removed, the user can leave/enter the app as much as they want and are always returned to the same activity that they were on when they minimized the app. Yet, Branch.io deeplinking is no longer respected.

HOWEVER, it seems that this minimize/restore behaivor is not (?) possible with Branch.io is implemented. Is it? How can I retain the minimize/restore functionality of my app, which implementing Branch.io deeplinking?

Brett
  • 11,637
  • 34
  • 127
  • 213
  • So when you have Branch integrated, what is the behavior when you minimize the App? Does the same Activity not open? – Amruta Deshmukh Aug 22 '17 at 19:31
  • @AmrutaDeshmukh When Branch.io is integrated correctly (ie, when `android:launchMode="singleTask"` is included in the manifest), the app **always** opens on the splash screen. – Brett Aug 22 '17 at 19:34
  • by minimize you mean just pressing the home button right and not completely closing the App. correct? I have a Sample App available on my Github Account – Amruta Deshmukh Aug 22 '17 at 19:51
  • That is correct. Oh yeah? I see branch_web on your github. That looks related to web though. Whats the repo called? – Brett Aug 22 '17 at 19:53
  • By minimize you mean just pressing the home button right and not completely closing the App. correct? Minimising the App should not cause your App to restart. I have a Sample App available on my Github Account [here](https://github.com/amruta-d/Sample-Android-App/tree/master/MyApplication). In this App, when you minimize the App and reopen it does not restart the App. – Amruta Deshmukh Aug 22 '17 at 20:03
  • I appreciate you posting that. However, that example actually contains the same issue that I am referring to in the post. For example, if you go to `RedActivity`, then minimize (via Home button), then resume (via app icon), then you are left back on the `MainActivity` view. If you remove `android:launchMode="singleTask"`, then the app will resume on `RedActivity` where the user was when they minimized. However, the Branch functionality is dead. – Brett Aug 22 '17 at 20:22
  • Ah, I see, when I resume via the app icon, it starts from a "closed" state. When I resume via "app expose", then it opens at the correct activity. Interesting... – Brett Aug 22 '17 at 20:26
  • 1
    unfortunately, that is default Android behavior. I.e. clicking on App icon will restart the Launcher Activity. Also, we require the ACtivity used for Deeplinking have the launch mode set to `SingleTask` to avoid creating multiple instances of the Activity in the Activity Stack. If you reset the Launch mode to default, it would open multiple instances of the same Activity and cause issues with deep linking. – Amruta Deshmukh Aug 28 '17 at 16:42
  • ok, thanks for the help. If you wrap that up in an answer, I'll accept it. – Brett Aug 29 '17 at 17:57

1 Answers1

0

In addition to Amruta's comment I wanted to contribute. As singleTask is required for proper deep linking to avoid multiple instances of the same activity, our best workaround/suggestion for this issue which hasn't been mentioned yet is to create a transparent deep linking activity. This way you can set a throw away transparent activity to singleTask, init session from it it -> grab params -> route accordingly. Otherwise you're stuck adjusting your main app flow to our requirement of using singleTask. This tends to be the most popular workaround!

Evan
  • 749
  • 6
  • 11