plaid / plaid-link-android

Plaid Link Android SDK
https://plaid.com/docs/link/android
MIT License
115 stars 48 forks source link

Handle process death/re-creation on Android properly #151

Open RyanNewsom opened 3 years ago

RyanNewsom commented 3 years ago

The problem

Android may kill activities when users background an app if the phone is currently resource constrained. To the user though, they simply backgrounded the app, and when they foreground the app, the state should be properly restored. This is not being handled properly for the Plaid SDK.

Actual:

Expected: When a user background our app and is in Plaid and the OS kills the activity, upon recreation, plaid should resume its previous state.

Environment

Android OS Version Android 11
Android Devices/Emulators Pixel 3 XL

Steps to Reproduce

If necessary, describe the problem you have been experiencing in more detail. Please include the configuration you are using for Link (exluding your keys and personally identifiable information)

Link Android SDK 3.2.6 I'm launching your SDK like so: Plaid.create(requireActivity().application, link).open(requireActivity())

1) Turn on do not keep activities 2) Launch Plaid, nav to a bank 3) Background app 4) Launch a different app 5) Come back to app that had Plaid showing 6) Observe that Plaid state is lost

Expected Result

Plaid should restore the users state and returning them to where they were.

Video

https://user-images.githubusercontent.com/11894221/113206468-5c4d9b80-9224-11eb-9c0a-663eb460f25b.mp4

Logs

Any relevant logs from Android Logcat or the iOS console including stacktraces.

Code To Reproduce Issue

Use your sample app, I bet it reproduces there too.

zsweigart commented 3 years ago

Hi @RyanNewsom Thanks for this feedback. Currently the SDK is showing a webview and our web implementation does not allow us to continue partway through the flow, except in the OAuth redirect case. You can test this by selecting Platypus OAuth Bank which will redirect out to a browser. Selecting one of the options to grant access, deny access or simulate error will redirect back to the application and on continue the flow at that point.

We agree that this is important functionality and are currently working on building it so it should be available in a future release.

RyanNewsom commented 3 years ago

Thanks for the reply @zsweigart. Here is how you can save/restore a WebView in Android. https://stackoverflow.com/questions/39086084/save-webview-state-on-screen-rotation

RyanNewsom commented 3 years ago

@zsweigart are you guys working on this? I had an old co worker at a different company reach out to see if I found a resolution to this because they are seeing the same problem. Only option would be to fork your sdk and patch it ourselves. Thanks

amytang0 commented 3 years ago

Hi Ryan, apologies for the staleness of the issue, OAuth has specifically been resolved in 3.4.1 and the issue with saving a user's place in the Link flow has been resolved and will be in our 3.5.0 release (and release candidate).

amytang0 commented 3 years ago

Hi Ryan, apologies, our QA ran through 3.5.0 with the DNKA flag off, and thus it looked like the issue was resolved, when in reality it was not. Unfortunately the helpful suggestion you gave earlier about saving WebView state doesn't quite work with our implementation, as the Bundle the WebView state provides is not actually sufficient to restore the correct state of the Link Flow.

We are working on a fully native flow where process death will be handled correctly.

RyanNewsom commented 3 years ago

Thanks for the update @amytang0

amytang0 commented 3 years ago

If you would like to opt-in to the fully native experience, please upgrade to the latest version 3.6.1 and email your client_id to android@plaid.com

RyanNewsom commented 2 years ago

@amytang0 how stable is the fully native experience?

djMax commented 2 years ago

I think this is still happening in React Native usage of the Plaid SDK. When the app is backgrounded with the Plaid SDK showing, it will kill the react-native MainActivity and then be forced to restart the app from scratch.

RyanNewsom commented 2 years ago

@djMax this has not been resolved, hence the open state. The recommended solution is to switch to their native sdk which (hopefully) has this resolved