Reputation: 726
I am developing an Ionic web application with capacitor and I'm facing an issue regarding the browser's refresh button. Whenever the refresh button is clicked in the browser, the entire Ionic app reloads, causing a loss of app state and data.
I would like to find a way to prevent the entire Ionic app from reloading when the browser's refresh button is triggered. Instead, I want only the current page to refresh while preserving the app's state and data.
I have tried using approaches such as configuring Cordova plugins and listening to the beforeunload event, but these methods do not prevent the app from reloading when the refresh button is clicked.
Is there any recommended solution or workaround to achieve this behavior in Ionic? I would greatly appreciate any insights, suggestions, or code examples that can help me tackle this issue. Thank you in advance for your assistance.
Upvotes: -1
Views: 783
Reputation: 929
You cannot prevent the entire Ionic app from reloading when the browser's refresh button is triggered.
If you want to preserve the app's state and data after a refresh, then you need to use some type of storage. Ionic provides @capacitor/preferences, that handles this great.
Upvotes: 1