capacitor-branch-deep-links icon indicating copy to clipboard operation
capacitor-branch-deep-links copied to clipboard

Android > Error: Session initialization already happened > No deeplink referringParams

Open KirstenStake opened this issue 4 years ago • 14 comments
trafficstars

Problem

When sending a push notification (in this case via Braze) which hold a deep link on click, if the app in the background, it only opens the application but does not hold any of the referringParams data and shows an error of:

"Warning. Session initialization already happened. To force a new session, set intent extra, "branch_force_new_session", to true."

Screen Shot 2021-10-29 at 1 00 12 pm

If you leave the app to go back into background, then foreground it again, it suddenly has the branch data within the object and works as intended. It is on the first push click and app open (if the app has already been opened and is in the background) that it is empty and fails.

Platform

Android

Code

  • MainActivity.java
public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Additional plugins you've installed go here
    // Ex: registerPlugin(TotallyAwesomePlugin.class);
    registerPlugin(Contacts.class);
    registerPlugin(NativeBiometric.class);
    registerPlugin(BranchDeepLinks.class);
  }

  @Override
  protected void onNewIntent(Intent intent) {
    // super.onNewIntent(intent);
    // this.setIntent(intent);

    this.setIntent(intent);
    super.onNewIntent(intent);

    // handles warning:"session initialization already happened"
    if(intent != null) {
      intent.putExtra("branch_force_new_session", true);
    }
  }
}
  • CustomApplicationClass.java
public class CustomApplicationClass extends MultiDexApplication {
    @Override
    public void onCreate() {
        super.onCreate();
        // Branch logging for debugging
        Branch.enableLogging();
        
        if (SDK_INT >= 24) {
          UserManager um = getApplicationContext().getSystemService(UserManager.class);
          if (um == null || !um.isUserUnlocked()) return;
        }

        // Branch object initialization
        Branch.getAutoInstance(this);
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}

Environment setup

  • Capcitor 3
  • Angular 12
  • "capacitor-branch-deep-links": "^4.0.0"

KirstenStake avatar Oct 29 '21 02:10 KirstenStake

I run into the same problem

webuniverseio avatar Jun 08 '22 23:06 webuniverseio

This issue still persists. It is especially apparent with in app popups and trying to deeplink from them. Screen Shot 2022-06-30 at 5 27 10 pm

KirstenStake avatar Jun 30 '22 07:06 KirstenStake

Acknowledged- we're currently designing some possible fixes for these types of errors/inconsistencies across plugins. Will keep you posted.

gdeluna-branch avatar Jul 07 '22 10:07 gdeluna-branch

I'm also facing the same issue.

Vishal-Isharani avatar Aug 17 '22 10:08 Vishal-Isharani

Facing the same issue, but had a question: Is there a way to use the Branch SDK to manually parse deeplink in the form of "https://dingo.app.link/Iy5o5phXYxb" without going through the BranchReferralInitListener?

JJSwigut avatar Mar 07 '23 20:03 JJSwigut

@gdeluna-branch I've discovered that this fixes this problem for me and haven't noticed any issues. Are there any unintended consequences to just including that extra preemptively?

JJSwigut avatar Mar 17 '23 16:03 JJSwigut

Hi ! Is there any updates to this? I am facing the same issue and couldn't solve with all above suggested solution. Please help me.

HendryZheng avatar Mar 18 '23 09:03 HendryZheng

any update?...

drakedeatonuk avatar May 16 '24 18:05 drakedeatonuk

Hi, @gdeluna-branch

any updates on this bug?

qliqdev avatar May 31 '24 19:05 qliqdev

bump

aaiach avatar Jul 01 '24 16:07 aaiach

Also seeing this with v8.1.0:

Intra-app linking (i.e. session reinitialization) requires an intent flag, "branch_force_new_session".

Not sure what the impact is yet and there's absolutely no documentation or any information regarding this, aside from a few open issues from years ago.

braincomb avatar Aug 21 '24 03:08 braincomb

still facing this issue even with the latest version..

marshall86 avatar Oct 16 '24 16:10 marshall86

The issue is still present with the latest plugin version. I found out that it can cause the app to crash. This happen when you click on a link generated using branchIo inside the app, once the app is opened and for example you have an integration with a plugin that open a webview like it happens with Jumio or anything similar

marshall86 avatar Oct 17 '24 07:10 marshall86