Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my Phonegap based hybrid app: Ajax calls start failing if my app is inactive for say a couple of minutes. My connection is WiFi & what happens is ajax calls fail with status 0; but navigator.connection.type still shows WiFi. This happens only on iOS not on android.

I can also see the WiFi icon with full signal strength, Other Apps like facebook etc. work fine using the WiFi.

I have really broken my head for the last couple of hours around this and i have no clue where and how to troubleshoot this. Any help is much appreciated. Thanks!

What I have tried:

I i noticed if the user keeps clicking around the app (thus initiating ajax calls which actually keep failing with status 0), he is able to bring the app back on track after say 2 minutes (i.e. suddenly the ajax calls start working and post that the app works perfectly fine). Seeing this behavior I created a loop that executes on failure every 5 seconds until finally the app is able to connect i.e. successfully execute ajax call after 2 minutes. (This is not feasible since no user will wait for 2 minutes for the app to connect back)

Other option i tried was to set the key UIRequiresPersistentWiFi in iOS property list file to YES (but this did not resolve the issue)
Posted
Updated 23-Feb-16 8:37am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900