Closed jf-branch closed 1 year ago
Hi @jf-branch .
This is one of the problems that was resolved with version 7, which is in beta, which was even updated today to use version 3.0 of the SDK for iOS.
In this new version it is necessary to initialize the SDK, making it possible to pass the parameters before initialization
Example:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
FlutterBranchSdk.setPreinstallCampaign('My Campaign Name');
FlutterBranchSdk.setPreinstallPartner('Branch \$3p Parameter Value');
FlutterBranchSdk.addFacebookPartnerParameter(
key: 'em',
value:
'11234e56af071e9c79927651156bd7a10bca8ac34672aba121056e2698ee7088');
FlutterBranchSdk.addSnapPartnerParameter(
key: 'hashed_email_address',
value:
'11234e56af071e9c79927651156bd7a10bca8ac34672aba121056e2698ee7088');
FlutterBranchSdk.setRequestMetadata('key1', 'value1');
FlutterBranchSdk.setRequestMetadata('key2', 'value2');
await FlutterBranchSdk.init(
useTestKey: false, enableLogging: false, disableTracking: false);
runApp(const MyApp());
}
It was a big change to the code and I spent some time testing to ensure that late initialization could work with all of the iOS and Android SDK initialization triggers.
For this reason I'm keeping it in beta.
Thanks @RodrigoSMarques! You know i had a feeling after reading through some of the beta PRs.
Let me inform the client to see if they are willing to test beta3 as well!
@jf-branch, version 7.0 released as stable
Which problem is this feature request solving?
Customers would like the ability to pass key<>value pairs through setRequestMetadata() before the initSession so it is applied to install (v1/install) requests.
Describe the solution you'd like
Ability to call setRequestMetadata() on the dart layer in order to
Describe alternatives you've considered
N/A
Can you submit a pull request?
No.
Hey Rodrigo, this is a bit of a tricky one, that might be worth hopping on a call with some of our engineers to architect a solution for support.
Essentially the issue is even with calling setRequestMetadata() before initSession().listen() there seems be a bit of a race condition where the SDK is initializing first because it is initialized during (br.com.rsmarques.flutter_branch_sdk) FlutterBranchSdkPlugin – onAttachedToEngine() regardless of the listen() call or not, which makes sense. However, this prevents certain preInit methods like this one.
The goal is to support associating the key<>value pair passed via setRequestMetadata() before the Branch initSession so that data is passed on v1/install and v1/open calls.
We did try to delay the session initialization through https://help.branch.io/developers-hub/docs/android-advanced-features#delay-session-initialization but that did not yield success.