-
Notifications
You must be signed in to change notification settings - Fork 6
InfoMobi: Tech Specs
// Returns TRUE if "deviceInformations" exists on localstorage
AppInfo.service.Device.isFirstConnection();
config.xml:
<access origin="tel:*" launch-external="yes" />
<allow-intent href="tel:*" />
HTML:
<a href="tel: 110">call</a>
If don't want to show the dialer, but call directly, then you should use the plugin CordovaCallNumberPlugin.
Source: PhoneGap Spain
Check on /api/login response if should_renew_password
Send mail to site.contact with predefined Title and Message
To check user's actual internet connection you can use the html5 api (window.navigator.onLine) or Cordova org.apache.cordova.network-information Plugin (navigator.connection.type).
Below you'll find an example of Device Service AppInfo.Device.isOnline()
app = {
Device: {
isOnline: function() {
var connection = false;
if (navigator.connection) {
var networkState = navigator.connection.type;
var states = {};
states[Connection.UNKNOWN] = false;
states[Connection.ETHERNET] = true;
states[Connection.WIFI] = true;
states[Connection.CELL_2G] = true;
states[Connection.CELL_3G] = true;
states[Connection.CELL_4G] = true;
states[Connection.CELL] = true;
states[Connection.NONE] = false;
connection = states[networkState] ? true : false;
} else {
connection = navigator.onLine;
}
return connection;
},
document.addEventListener("offline", onOffline, false);
function onOffline() {
// Handle the offline event
}
But if you want to check connection between your server and the client you can write an interceptor. When we get a 0 status, we are offline. This is triggered for any AJAX call that uses $http. It's well documented on Ionic doc Global Loading Screen with Interceptors.
See below our implementation on meumobi-api.js:
return {
request: function(config) {
$rootScope.$broadcast('loading:show');
return config || $q.when(config);
},
requestError: function(request) {
$rootScope.$broadcast('loading:hide');
return $q.reject(request);
},
response: function(response) {
$rootScope.$broadcast('loading:hide');
return response || $q.when(response);
},
responseError: function(response) {
$rootScope.$broadcast('loading:hide');
if (response && response.status === 0) {} // network offline or CORS error
if (response && response.status === 404) {}
if (response && response.status === 401) {
delete localStorage.userToken;
delete localStorage.mail;
$rootScope.go('/login');
}
if (response && response.status >= 500) {}
return $q.reject(response);
}
};
See below the list of API requests infomobi does:
- POST /visitors/login
- POST /visitors/devices
- PUT /visitors/devices
- GET /items/latest
- POST /contact
- POST /mail