Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Conflict with the Splashscreen plugin when starting the app offline #92

Closed
pauloya opened this issue Nov 2, 2016 · 11 comments
Closed
Labels
Milestone

Comments

@pauloya
Copy link

pauloya commented Nov 2, 2016

Hi,
I'm testing an iOS app, using the cordova-plugin-splashscreen to control when the splashscreen goes away programmatically. The problem is that when the app starts offline I can't hide the asplashscreen, even if I set the configuration to have "AutoHideSplashScreen" to "true", or if I call the hide method: navigator.splashscreen.hide();

I've tried this both using the default offline page and a custom one.

When I reconnect the device to wifi the splashscreen hides and the remote site is shown correctly.

@boyofgreen
Copy link
Contributor

Hi @pauloya it sounds like we are not firing an event that the cordova-plugin-splashscreen is looking for. So for clarity, the splash screen shows instead of the offline page, not on top of it correct? And it fails if it is set to auto and if it is set to timed delay?
Also, does it fix it if you add this js to the offline page:

window.setTimeout(function () {     navigator.splashscreen.hide(); }, 0);

@pauloya
Copy link
Author

pauloya commented Nov 4, 2016

I'm attaching macOS Safari debugger to the iOS device, and I see that the offline page is there.
My custom offline page loads the cordova.js
<script type="text/javascript" src="cordova.js"></script>

So when I try to call from the console:
navigator.splashscreen.hide();
nothing happens, I tried setting a breakpoint in the splashscreen ObjectiveC code and that doesn't seem to get hit when I call hide()...
I think the issue may be related with the fact that the offline page is not correctly bound with the cordova APIs...

@pauloya
Copy link
Author

pauloya commented Nov 7, 2016

Just to clarify, is there anything different about the offline page that prevents cordova APIs to work correctly? I noticed that when hooking the Safari devtools with the app there are 2 different instances of browser that show up, is this because the offline page is rendered inside a non standard cordova webview?

@boyofgreen
Copy link
Contributor

The reason why we use two different webviews is so that when you go back online, we can just switch webviews and keep you in context. With iOS we would often get a page refresh where we would loose the session info.
Your assumption is correct, we don't have the cordova environment on the offline page and we should for this scenario. If you are using the local plugin structure, you should be able to just solve it by hard coding a link to local js files.

@boyofgreen boyofgreen added this to the release-0.4.0 milestone Nov 8, 2016
@boyofgreen boyofgreen added the bug label Nov 8, 2016
@pauloya
Copy link
Author

pauloya commented Nov 21, 2016

I'm sure you know this better than me, but a quick look at the code indicates the offline view is a [UIWebView] which, perhaps doesn't bind access with Cordova even though I include it. [CDVViewController] should work instead.
Also, I think you would need to inject the plugins JS in the offline page for this to work.

@Yuripetusko
Copy link

Also seeing it. If network status changes after hosted url has been loaded then offline page is shown, but If I start the app while offline then i'm stuck on splashscreen

@boyofgreen
Copy link
Contributor

Hi @pauloya I do remember some issue with offline, splashscreen and cordova APIs. @f2bo , @DaveVoyles or @jasonshortphd did any of you help fix a problem like this?

@Yuripetusko
Copy link

Looks like since url in <content src="..." /> never loads and we are not loading local files where we can do navigator.splashscreen.hide() there's no event that hides splashscreen,

@f2bo
Copy link
Contributor

f2bo commented Jan 17, 2017

Hi @pauloya I do remember some issue with offline, splashscreen and cordova APIs. @f2bo , @DaveVoyles or @jasonshortphd did any of you help fix a problem like this?

@boyofgreen Yes. We did fix an issue (#59) with offline in iOS, but it was a different scenario.

@pauloya Just to confirm, do you mean you see the splashscreen instead of the offline page while the device is offline?

@pauloya
Copy link
Author

pauloya commented Feb 9, 2017

We found a workaround for this.

@pauloya Just to confirm, do you mean you see the splashscreen instead of the offline page while the device is offline?

Yes, the problem was that the splashscreen stayed on when the device was offline.

The workaround is to open a local HTML that does a document.location.href = "..."; to redirect to the remote host.

We looked at the splashscreen code and it relies on a pageload event to start any logic of hiding the splashscreen even when using a delay splashscreen. If you use the splashscreen plugin and there is no page load the splashscreen will never go away.

We set up a delay of 10s on the splashscreen and we call navigator.splashcreen.hide() from the hosted web app. It's not the ideal solution because of the delay of 10s when the device is offline, but we can live with it.

@danzel
Copy link

danzel commented Apr 2, 2017

This is my work around:

danzel/cordova-plugin-splashscreen@3974118

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants