Pulsar Online Status API

Online Status
getOnlineStatus

The getOnlineStatus operation will return Pulsar's current "online" status. If the user is working offline, whether by disconnecting the device from the network or toggling the "Work Offline" switch in the app, this will return the string "FALSE". If online, this operation will return the string "TRUE".

var request = { 
	"type" : "getOnlineStatus",
	"data" : { } // empty object- this is required in the current API
};

bridge.sendRequest(request, function (results) {
	console.log('Javascript got its response: ' + results);
    if (results.type === "getOnlineStatusResponse")	{
		var isOnline = results.data; //string value "TRUE" or "FALSE"
		// do something with the information
    } else if (results.type == 'error') {
	    errStr = results.data;
	    alert('A problem occurred:\n' + errStr);
    }
});    
setOnlineStatus

The setOnlineStatus operation will attempt to change Pulsar's current "online" status. Sending "True" will request an online status, and sending "False" will request an offline status. If the user is offline and requesting to work online (sends "True") and the operation is successful, this will return the string "TRUE". If unsuccessful, such as if the network is disconnected, Pulsar is still offline, and this operation will return the string "FALSE".

var request = { 
	"type" : "setOnlineStatus",
	"data" : "FALSE"
};

bridge.sendRequest(request, function (results) {
	console.log('Javascript got its response: ' + results);
    if (results.type === "setOnlineStatusResponse")	{
		var isOnline = results.data; // string value "TRUE" or "FALSE"
		// do something with the information
    } else if (results.type == 'error') {
	    errStr = results.data;
	    alert('A problem occurred:\n' + errStr);
    }
});    

OnlineStatus refers to  Pulsar's current "online" status. The app has a set of rules it follows to determine the status than a simple check for a network connection (data or WiFi). If your custom code requires a simple check like that to connect to a URL, just use the Javascript built-in check. For example, window.navigator.onLine would probably give you the result you are looking for.

Network Status
getNetworkStatus

The getNetworkStatus operation will return your device’s current network status. If wifi is off, cell data is enabled on the device, but the Pulsar App itself is not enabled for cell data, the return ‘isConnected’ value will show “FALSE”. If there is connectivity, but the type could not be determined as Wifi or Cellular, then Unknown value will be reported.

 var request = {
	 "type" : "getNetworkStatus" 
};
 
bridge.sendRequest(request, function (results) {
    console.log('Javascript got its response: ' + results);
    if (results.type === "getNetworkStatusResponse") { 
        var isOnline = results.data['isConnected']; //string value "TRUE" or "FALSE"
        var connectType = results.data['connectionType']; //string value “Wifi”, “Cellular”, “Unknown”
        // do something with the information 
    } else if (results.type == 'error') { 
        errStr = results.data; 
        alert('A problem occurred:\n' + errStr); 
    } 
});