Window.location.reload(true) creates two instances of objects/execution


#1

I’m working on an Ionic 3 app with several plugins including cordova-googlemaps and cordova-geolocation. I would like to handle cases when my app is task switched and brought back from background, especially during app launch, the startup process of determining geolocation and loading google maps should run to completion.

At present, during app launch, if the app goes to background 2 adverse events happen:

  1. determining geolocation times out
  2. google maps displays a blank white screen

To overcome this, I tried subscribing to platform.resume event and executing:

this.platform.resume.subscribe((e) => {
  window.location.reload(true);
});

But, the above code when it executes results in Google Maps loading twice and many lines of code getting executed twice. I’ve tried to use .setRoot method of navController and that also results in Google maps loading twice, etc.

Is there a better approach to solve the task switch - app resume events?
Thanks for your time.