-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Completion of await FlutterBranchSdk.init()
doesn't mean native iOS plugin is ready?
#309
Comments
Hi @romatallinn the purpose of the If during code execution (setupBranch) the SDK There is an issue in which it was mentioned that during the first launch, the SDK may take longer to find the installation data. Some suggest adding a delay to get around the problem. In the example application, I identified this condition at times. If you look here you will find a commented code, where I add a delay of 3 seconds. This worked in my tests. I never wanted to "official" this as a solution, as it is not correct, but in my tests it worked. |
Hi @romatallinn The I'm already working on a new version that should resolve these issues. |
@RodrigoSMarques thanks a lot for the release. So, just to confirm, |
Hi @romatallinn In version 8.0.0, the plugin has the same behavior as versions prior to 7.x.x The native SDK is initialized even before Dart/Flutter code is executed. Initialization is not delayed. The For this reason, it is no longer possible to configure the test key via code, so as not to delay initialization. Deferring startup was causing data loss by not recognizing link clicks on application startup. |
I am facing the same issue again. I am using the flutter branch sdk that is 8.0.2. |
Describe the bug
Completion of
await FlutterBranchSdk.init()
doesn't necessarily mean native iOS plugin is fully initialized? Especially during the first launch.In my app:
await FlutterBranchSdk.init()
listSession()
Sometimes, especially during the first launch, the app won't catch links (not deferred, but ones I try to open with app installed). It opens the app, but not the link.
And I noticed that during app launch in XCode's console it produced this log:
[BranchSDK][Debug][Branch initSafetyCheck] Branch avoided an error by preemptively initializing.
Googling it, I discovered multiple issues BranchMetrics/ios-branch-deep-linking-attribution#936 and RodrigoSMarques/flutter_branch_sdk#168.
At first, I thought that somehow I was throwing some events too early, before init'ing. But eventually got assured that nothing to branch happens before
await FlutterBranchSdk.init()
is completed. Trying out some recommendations, I set extra hardcoded delay afterawait FlutterBranchSdk.init()
, which seems to help.So, I digged into init() through platform channels, and discovered that iOS's channel method does not wait for banch's native sdk to complete session initialization. It returns result prematurely, from what I understand.
So it triggers branch's native sdk initSession on line 331 with async completion handler, but result is returned prematurely on lines 331-332, without completion of the initSession.
The text was updated successfully, but these errors were encountered: