Closed DouglasCeron closed 1 month ago
Hi @DouglasCeron
The Branch SDK monitors deeplinks in the native layer and triggers the listen plugin method in Dart.
From version 6.9.x to 8.x.x of the plugin there was no change in the code regarding the call to the listen method.
The Branch SDK between the version used in 6.9.x and 8.xx of the plugin had several releases.
I don't know if there was any change in the Branch SDK regarding the behavior in the foreground.
Never use In-App Message, but with the application in the foreground you can call the
FlutterBranchSdk.handleDeepLink(url)
method to force the execution of the listen method for a URL.
@DouglasCeron
While reviewing Branch's implementation instructions regarding receiving a new intent, I noticed a difference in the code between the plugin versions.
I'm looking into it.
@DouglasCeron
Branch's instructions for implementing SDK calls on Android have changed since the versions used in the plugin in version 6.9.0.
For this reason, it does not work from version 7.x.x
The instructions in question are in the onNewIntent method on Android, which is triggered after a deeplink call.
The plugin follows what is described in the documentation and cannot be undone.
For your scenario, my suggestion is to call
FlutterBranchSdk.handleDeepLink(url),
as mentioned previously.
@RodrigoSMarques Could you try
Hi @DouglasCeron
The Branch SDK monitors deeplinks in the native layer and triggers the listen plugin method in Dart.
From version 6.9.x to 8.x.x of the plugin there was no change in the code regarding the call to the listen method.
The Branch SDK between the version used in 6.9.x and 8.xx of the plugin had several releases.
I don't know if there was any change in the Branch SDK regarding the behavior in the foreground.
Never use In-App Message, but with the application in the foreground you can call the
FlutterBranchSdk.handleDeepLink(url)
method to force the execution of the listen method for a URL.
Could you please attempt to display an in-app message while the app is in the foreground? Still trying to figure out how to add FlutterBranchSdk.handleDeepLink(url) when the .listen doesn't trigger, preventing me from taking the URL and adding it to the method.
To reinforce, could you try using the adb command as I added before on How to Reproduce: leave your App open ( foregrounded ), and add some breakpoints to see if the Branch will listen. On the terminal insert the command " adb shell am start -a android.intent.action.VIEW -d "https://'your-test-link-here'/ ".
About the FlutterBranchSdk.handDeepLink(URL), I talked to the team about using it, and this workaround will bring more tests and changes as we will need to access some native code. Could you please reconsider making a change on your end after testing?
To reinforce, could you try using the adb command as I added before on How to Reproduce: leave your App open ( foregrounded ), and add some breakpoints to see if the Branch will listen. On the terminal insert the command " adb shell am start -a android.intent.action.VIEW -d "https://'your-test-link-here'/ ".
About the FlutterBranchSdk.handDeepLink(URL), I talked to the team about using it, and this workaround will bring more tests and changes as we will need to access some native code. Could you please reconsider making a change on your end after testing?
It will not be possible to revert the code, as I do not know the impact.
The plugin follows the implementation instructions found in the Branch documentation.
The change is in the onNewIntent method
version 6.9.0
@Override
public boolean onNewIntent(Intent intent) {
LogUtils.debug(DEBUG_NAME, "onNewIntent call");
if (this.activity == null) {
return false;
}
if (intent == null) {
return false;
}
Intent newIntent = intent;
if (!intent.hasExtra("branch_force_new_session")) {
newIntent.putExtra("branch_force_new_session",true);
}
this.activity.setIntent(newIntent);
Branch.sessionBuilder(this.activity).withCallback(branchReferralInitListener).reInit();
return true;
}
version > 7.x.x
@Override
public boolean onNewIntent(@NonNull Intent intent) {
LogUtils.debug(DEBUG_NAME, "triggered onNewIntent");
if (this.activity == null) {
return false;
}
this.activity.setIntent(intent);
if (intent.hasExtra("branch_force_new_session") && intent.getBooleanExtra("branch_force_new_session",false)) {
Branch.sessionBuilder(this.activity).withCallback(branchReferralInitListener).reInit();
LogUtils.debug(DEBUG_NAME, "triggered SessionBuilder reInit");
}
return true;
}
When a new intent was received, a 'branch_force_new_session' was added to that intent and then the SDK's reInit method was called, triggering the onListen method.
Starting with plugin version 7, the reInit method will only be called if the intent already has branch_force_new_session.
These instructions are here
When you call the handleDeepLink method it adds branch_force_new_session to the intent and through it it works.
private void handleDeepLink(final MethodCall call) {
LogUtils.debug(DEBUG_NAME, "triggered handleDeepLink");
if (!(call.arguments instanceof Map)) {
throw new IllegalArgumentException("Map argument expected");
}
final String url = call.argument("url");
Intent intent = new Intent(context, activity.getClass());
intent.putExtra("branch", url);
intent.putExtra("branch_force_new_session", true);
activity.startActivity(intent);
}
Closed. No activity in the last 14 days. If necessary open again.
Keep the template and provide all requested information:
Describe the bug Only when using on Android When using an old version of Branch 6.9.0, the app worked fine, receiving In-App messages backgrounded and foregrounded. But using a higher version from 7.0.0 to 8.1.1 the App does not trigger the .listen so we can get the data in it when receiving an IAM (app foreground)
To Reproduce
On both ways, when the app is foregrounded the .listen does not trigger
Expected behavior The expected behavior is the .listen being triggered, properly reading the data, and in case it has a path it should navigate to a specific screen, which is not happening
Mobile (Please complete the following information. Remove session if not Mobile):
Device: Google Pixel
Additional context
When using -- adb shell am start -a android.intent.action.VIEW -d "https://your-test-link" -- command or a in-app message:
App Backgrounded:
it works just fine. The .listen gets the data
App Foregrounded:
it does not work. .listen does not trigger.
Add any other context about the problem here.
We have been using the Branch for a long time, but when we upgraded from 6.9.0 to a newer version it stopped working for the related issue above. So to keep things working we are using version 6.9.0 for now. On this version, everything works fine, we are receiving the in-app messages and navigating the user across the app, but when upgrading it to a new version 7.0.0 or higher, Android just does not work as it should in the foreground, .listen is not triggered. When in the background the .listen is triggered.