Closed henrygrant closed 9 months ago
@henrygrant thanks for the detailed report. I just tested our example application and both the success and the exit callback are called as expected on Android. Given the unique nature of your application I think the problem is rather specific. I am happy to help where I can, but I am currently not sure what could be causing this 🤔
Update to this for anyone who may have the same issue in the future:
The root of it is that the activity that our React Native fragment is running in, i.e. the activity that PlaidLink is being launched from, doesn't subclass ReactActivity. Looking at RN's "Integration with an Android Fragment" doc, it shouldn't have to. We have our MainApplication.kt configured for ReactNative, and can use a React Native fragment in any of our native activities without issue. This is the first I've seen an issue with this setup.
Their ReactFragment overrides onActivityResult, but it doesn't seem like react-native-plaid-link-sdk plays well with this. I'm going to investigate a bit further, as I can't tell if this is an issue on the RN side or the react-native-plaid-link-sdk side.
For the time being, I've changed the activity that loads our ReactNative fragment to subclass ReactActivity, but I don't really want to use this as a long term solution.
@henrygrant any update on this issue? I'd like to close this if possible 🙏
I haven't had the chance to dig into this as the workaround is working for now. You can close this, but you may want to update the documentation with something that says Plaid Link needs to be run in an activity that subclasses ReactActivity, else your callbacks won't fire. RN doesn't require you to sub ReactActivity if you're using a ReactFragment, so this is a fairly easy trap to fall into if you're working in a brownfield/hybrid project, but as this is pretty nonconventional I'll leave it up to you to determine if it's important enough to mention 😆
Thanks!
The problem
Neither the onSuccess nor the onFailure callback is ever firing from
openLink()
. I traced this back toPlaidModule.onActivityResult()
never firing at all, meaning this is likely an issue with the implementation of ActivityEventListener in that file (PlaidModule.kt).It doesn't seem like PlaidModule's
onActivityResult()
is hooking intoLinkActivity
properly.Environment
Steps to Reproduce
One of my teams is using
openLink
as so, and have asked me why their callback functions never fire when the Plaid experience is exited/completed.I spun this up locally saw the same thing. After running the android debugger for a bit, I'm seeing that
PlaidModule.kt onActivityResult()
is never getting called.Expected Result
I'd expect
onActivityResult
to fire when the Plaid experience is closed.Logs
Not getting anything relevant in the logs
I did run the flow with the profiler to see what was going on. Our RN application runs in a Fragment inside an Activity.
Code To Reproduce Issue
It's really just what you see above, but it may be worth noting that I am working in a brownfielded React Native app, and Plaid is also used on the native side. When I first got this bug I assumed the version of Plaid the native app was using was mismatched with the version of
react-native-plaid-link-sdk
we're using, and that was true. I went ahead and made sure they were synced, but to no avail.My Android project:![image](https://github.com/plaid/react-native-plaid-link-sdk/assets/12072806/37984658-9401-47b0-acf8-c3abc5b25a68)
It may also be worth noting that the android project is the parent project in this implementation, and the react native app is a package. The dir structure looks like this:
myreactnativeapp
specifiesreact-native-plaid-link-sdk
as a peerDependency.Other notes
getPackages()
this.getReactNativeHost().getReactInstanceManager().createReactContextInBackground();
in MyApplication.java's onCreate(). I can't get around this, but I'm curious if that could be causing this behavior. I was concerned thatPlaidModule.initialize()
may have been happening too early (like in the wrong activity), but that wasn't the case. It executes when the the Plaid Activity starts up.