Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I refresh iOS homescreen PWA on app reopen

I have created a PWA which is validated by the Google Chrome Lighthouse audit tool. On Android Phones the native "Add to Homescreen" prompt is displayed and on iOS, a custom "Add to Homescreen" prompt is shown.

The problem is that on iOS the PWA saves the session and I am not redirected to the "start_url".

I need an option to always direct users to the "start_url" if they close the app and reopen it afterward.

Here are the PWA files: https://www.ta-systems.net/BE-Utilities/pwc/test/

I have tried mentioned in the PWA documentation, however, I was not able to get the App to refresh every time it is restarted.

The complete code can be found here: https://www.ta-systems.net/BE-Utilities/pwc/test/

The expected result should be that the application redirects to a different HTML page after 5 seconds & once the app is closed and relaunched the "start_url" should be reopened.

What happens at the moment is the following:

  1. I open the "timesheet.html" document & I am prompted to add the PWA to the home screen.
  2. I add the app to the home screen.
  3. I open the app from the home screen & I am redirected to "redirect.html".
  4. I close the app & reopen it but the "start_url" (timesheet.html) is not opened.
  5. The app is stuck on the "redirect.html" screen.
like image 289
TudorAnghelina Avatar asked Jul 31 '19 13:07

TudorAnghelina


1 Answers

What happened for your PWA is that it saved the session state after you closed it. Starting iOS 12.2, Apple fixed PWA so that it is able to keep PWA session state. However, there is still a problem that Apple needs to fix: it saves the state regardless if you minimize the app (by going to home screen) or close it (by swiping up on app-switch mode). According to this article (https://wespeter.com/posts/ios13-pwa-improvements/) Apple will be fixing in iOS 13 so that it starts your PWA from scratch (start_url) after force quit by swiping up, and only keeps the state when minimize to home screen without force quit and reopen.

like image 113
Rony Avatar answered Sep 18 '22 15:09

Rony