[IONIC-3] Location of Error Page html file in config.xml inside IONIC project, to be used when offline/ no network connection, to show error message

Hi all,

We are working on an Ionic app for an enterprise product.
All of the data/content/web assets used in the project are loaded from remote location like S3.

In config.xml, the path to index.html can be like this for example

Due to this, we need to handle the ‘no network/ internet’ scenario.

config.xml has an option ‘ErrorUrl’ which should point to errorPage.html.

My question is,

In an IONIC project, where should this error html page reside & what should it’s path be in config.xml ???

Following are the links for reference that I have gone through but didn’t get any concrete answer,

https://cordova.apache.org/docs/en/latest/config_ref/#preference
(Search for ErrorUrl property)

https://www.raymondcamden.com/2013/02/19/Some-examples-of-Android-PhoneGap-Config-Settings

Please help me with this !

Thanks in advance :slight_smile:

This file should be at the root directory (ie within the www folder). However, it appears you need to address it with a complete path, meaning adjusting the config.xml file for each build.

Personally, I would have a simple index.html that performs the network check, then redirects as needed.

Thanks for the answer.
If you generate ionic-3 project with cli, then should Error page html file be located at /src folder level or inside src ?

Can you please tell me what should be complete path of the file ?
Do you have a git repo that I can refer to ?

In my case, please note that, even the index.html file will have ABSOLUTE path pointing to a REMOTE location and it wont be served locally when user will use the app in device.

Please help me !!!

Every time you build the www folder is recreated, so you will need to manually add the error.html file back in. You could adjust the build scripts, or just do it old-school and copy it.

According to what I have quickly read it the path starts with file://

Why not test some solutions and see what works?

Do you mean the www folder that is at /src level ?

or some other www in platforms folder ?

Kindly clarify sir please.

Kindly kindly help me please.

Please see attached image

image

yes inside www folder where is index.html
Create one error.html and put your code there so everytime you build you have to add error.html where is index.html
this should be in config.xml
<preference name=“errorUrl” value=“file:///android_asset/www/error.html” />

Dear Indraraj,

I want to show error message to user when there is no internet connection.

Whole code in my Ionic 3 app, including index.html, comes from remote location.

In such a case, will errorUrl html page handle no internet connection error ?

I will try and update you on results.

If you dont mind, can we have a quick Skype call for this ?

i dont think so that will work for network connection i read the docs of cordova errorUrl is for when the error is in application only that time it will show that error.html

Try this approach
now what you can do is make separate page for it
Use network native plugin in app.component.ts in constructor check the is he/she connected to internet then rootpage will be default else root page will be error page

Ok thanks will try :slight_smile:
Is your name Raja Das ?

If yes I have pinged you on Skype.

no i am not on skype. message me private will share my fb id or whatspp number

Please send me Whatsapp number or FB id