dpa99c / cordova-diagnostic-plugin

Cordova/Phonegap plugin to manage device settings
540 stars 361 forks source link

Any chance we could have restart on iOS as well? #523

Closed igorsantos07 closed 2 months ago

igorsantos07 commented 2 months ago

Feature request

The Android-only feature of restart() could be very useful for my project, but we would need it to work on iOS as well. I haven't researched alternative solutions so far - in fact, I stumbled upon this idea while looking for permission solutions. But I'm wondering: is there any chance the restart could be implemented on iOS as well, or there's a technical reason it wouldn't ever work?

dpa99c commented 2 months ago

It's not programmatically possible to natively restart a Cordova app on iOS in the same way as for Android. While some pseudo-restart behaviour is suggested in this SO post, in a Cordova app this won't work because the app delegate functions that Cordova uses as hooks to bootstrap itself will not be fired again, so you'd have to rewrite part of the Cordova iOS platform code to try to make it work.

If you just want to reset the state of the JS layer, you could use window.location.reload() to reload the Cordova webapp in the Webview.