I'm developing a PWA and came across this problem on a payment page. Basically:
Scenario 1
- User fills payment form
- Hits submit, is redirected to 3rd party payment page - Stripe (this opens a tab in Chrome on mobile, and can't be tweaked to open a modal like on desktop)
- Payment successful, the 3rd party page redirects to the PWA, which automatically restarts.
The problem is that I have a success page that can't be displayed because when restarting I lose the entire state I was in.
Scenario 2
- User fills payment form
- Hits back button/home button on phone
- From desktop, opens app again. Sometimes the app opens back in the previous state (with the form filled), sometimes it restarts, again, losing everything.
Is there anything I can do to prevent this? I know that when you open a PWA icon from desktop you're basically opening chrome. But if the app was already opened (and it's still visible in the Recent Tab), is there anything I can do to prevent it from restarting? I guess the phone automatically shuts it down.
Possible solution:
The only one thing I can think of right now is storing everything in localStorage and trying to reload on refresh. This way I can ensure that even if it closes and opens again I remain with the previous state.
Funny thing is that scenario 1 (which bothers me the most) only happens on Samsung Galaxy S7 (tested 6-7 devices until now, and it's the only one it reproduces on). Chrome versions are mostly the same on all of them.
Any ideas? Thanks!