Hi, I would like to have an icon in the ios/android app that displays whether the user is currently online or offline and use that information to make certain functionality available, I am assuming that I could conditionally set the style of a font awesome icon to make it coloured or greyed out. Is the global App.Online variable the best thing to use for this in Cordova and would I need to use a watcher on that variable? I am having a hard time getting it to pick up any changes in the online/offline status. I also see the online/offline tabs in the script editor. Would that be a better approach?
Thanks,
Pete
Hello Peter,
In certain app that I am developing for Android and iOS we use the Online / Offline event with good results. I think the description of the "App.Online" variable can be take as the best advise:
This variable store "true" if the app is considered online or "false" when not. Take also a look at the Online and Offline app events. This variable apparently do not work in the Cordova platform. If you plain to build your application with Apache Cordova, use the GetNetworkType action and the Network plugin for Apache Cordova.
Hi,
Yes, I have that working now. The issue that I am having is for the view to detect in live time if the user goes online or offline while they are on a view. I have it working to set the icon colour when they land on a view but need a little help in 'watching' for an the offline/online event. Right now you need to interact with the view in order for it to change colour.
Pete
Hi Peter,
A good idea could be using a timer in every seconds to detect if the app in online/offline.
Hello to all,
Certainly, a Timer control can be a solution. However, we have the "Online" and "Offline" app's events, and, also the "App.Online" variable. With this variable we can use an HTML markup like the below inside an HTML control:
Without doing anything else, when "App.Online" are "true", what we can see is the "Online" text, and, when "App.Online" become "false", what we can see is the "Offline" text.
On the other hand the app's Online and Offline events can be used anyway if we needed. That is, if we are using another control, not an HTML control, we can use that events in order to show or hide that control / indicator.
Thanks guys, looks like a timer is the way to go. Thanks for your help.
Pete
Hello Peter,
Maybe I am wrong, but, even when a Timer can be a solution... why not to use the solution proposed in my last post, that do not require a Timer at all? (I am curious... :)
Hi David,
On some views I need the online indicator icon to reflect the current state in live time so that if they go online or offline, the icon reflects that change while still in the same view. I haven't been able to find a way to get it to 'watch' for that change and change by itself. In the case of your example, the html area value only changes when you come into the view or interact with the view in some manner such as by clicking on another button that fires off any event. Am I missing something?
Hello to all,
If you place the above HTML code inside an HTML control, you must see "Online" or "Offline", Peter, without doing anything else.
Yes, I do see online or offline but if I am on that view and turn internet connectivity off, it still says online until I somehow interact with the view or leave the view and come back to it.
Hello to all,
You are right, Peter. Please, use the same HTML code than above, but, place this action in both Online and Offline app's events:
Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.