cancel
Showing results for 
Search instead for 
Did you mean: 

How to check for hybrid application is offline or online while launching application in SUP 2.2

Former Member
0 Kudos

HI,

How can we check for the network status in SUP hybrid app.

I am aware of achieving through registering listeners but i want to know the network status when my app is launched.

Thanks,

Ankit

Accepted Solutions (0)

Answers (1)

Answers (1)

midhun_vp
Active Contributor
0 Kudos

The HWC based hybrid apps are developed using HTML, JavaScript and CSS. So you have to write javascript code to to check the availablity of internet.

In the custom.js file inside the generated WF you can find methods like customBeforeWorkflowLoad()and customAfterWorkflowLoad(). These methods will be first called once you run the app from the device. So you have to write the code inside of these functions ( any one ) to check the availability of the internet.

Try using these example code:

var online = window.navigator.onLine;
   
if (!online) {
        alert
('Please check your internet connection and try again.');
   
}
   
function checkInternet() {
       
var online = window.navigator.onLine;
       
if (!online) {
            alert
('Please check your internet connection and try again.');
       
}
   
}

The code above I have taken from internet but didn't try it. You may have to modify it to make it working. If I get a chance to try the code I will try and update.

- Midhun VP

Former Member
0 Kudos

I tried this code but its not working.

also i am using sup 2.2 so in my code i do not have any custom.js file , but there are generated hybrid app api , js files.