stripe-react-native icon indicating copy to clipboard operation
stripe-react-native copied to clipboard

Update example app to use two activities

Open stianjensen opened this issue 2 years ago • 3 comments
trafficstars

Using singleTask in an Android application for the activity that has an intent-filter on the LAUNCHER, means that any activities running on top of this activity will disappear when the app's icon is pressed again from the launcher.

This is a problem, because when confirming a SetupIntent or PaymentIntent, Stripe may need to present a web browser (its own activity) for verification with a customer's bank or similar, and the user may even need to leave this web browser activity temporarily to navigate to their bank's own application. If the user is not careful when navigating back to the original app, and taps the app's icon from the launcher, the app will open to its original activity, and the web browser is gone. Instead, the user will need to navigate back only using Android's app switcher, which will correctly bring you back into the open web browser activity.

The change in this commit side-steps this issue by splitting the example application into two acitivites. One that is only responsible for launching the application, and a second activity that actually represents the react native application, and will be started by the first activity, ensuring to only start it once.

This fixes #355.

Testing

  • [ ] I tested this manually
  • [ ] I added automated tests

Documentation

Select one:

  • [ ] I have added relevant documentation for my changes.
  • [x] This PR does not result in any developer-facing changes.

stianjensen avatar Sep 12 '23 20:09 stianjensen

I based this on the fix originally described here: https://github.com/proyecto26/react-native-inappbrowser/issues/213#issuecomment-878915862

It may be that the code can be further simplified, by not even maintaining a list, since in my experiments, I've never seen that it's possible for the activity to be started more than once (which makes sense, since it has launchMode 'singleTask). But for now I kept it like this, since it's equivalent to the code we ended up deploying to production.

stianjensen avatar Sep 12 '23 20:09 stianjensen

what about expo apps using managed workflow?

zdnk avatar Sep 19 '23 21:09 zdnk

what about expo apps using managed workflow?

I'm not sure, and not really that familiar with android activites except what I've been forced to try to understand while debugging and fixing the issue in our react native app.

I would assume that the issue is something expo would need to support in their native code – but unsure if they could do it without risking breaking some other use case.

I still think there's not much Stripe could do about it without abandoning the use of chrome custom tabs altogether though (and that's not really an option for 3d secure flows either).

stianjensen avatar Sep 25 '23 20:09 stianjensen