Is it possible to check
a device has SIM card in meteor
This has worked for me in the past.
var networkState = navigator.connection.type;
var states = {};
states[Connection.UNKNOWN] = 'Unknown connection';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WiFi connection';
states[Connection.CELL_2G] = 'Cell 2G connection';
states[Connection.CELL_3G] = 'Cell 3G connection';
states[Connection.CELL_4G] = 'Cell 4G connection';
states[Connection.CELL] = 'Cell generic connection';
states[Connection.NONE] = 'No network connection';
alert('Connection type: ' + states[networkState]);
If navigator.connection.type = CELL_2G or CELL_3G or CELL_4G or just CELL, then I’d imagine the device has a SIM card.
I can’t remember whether I needed to add a package though…
1 Like
I don’t think that is a good solution since if the device is connected via WIFI, the condition will fail. Use this plugin, i guess if it throws an error, the device is lacking a simcard. (disclaimer - I’ve never used it, just googled for 2 seconds)