blob: c9cb77fe8e0a667cd0197ed2d8c7caab4ba20053 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
var sim = (function(){
var sim = {}
sim.loaded = false
sim.data = {
carrierName: 'unknown',
countryCode: 'us',
mcc: '0',
mnc: '0',
}
sim.fetch = function(cb){
sim.afterFetch = cb
window.plugins.sim.getSimInfo(sim.success, sim.error)
}
sim.afterFetch = function(){}
sim.success = function(data){
console.log(data)
sim.data = data
sim.data.countryCode = sim.data.countryCode.toLowerCase()
// app is only available in US or Canada, so call the US API regardless
if (sim.data.countryCode !== 'ca') {
sim.data.countryCode = 'us'
}
sim.loaded = true
sim.afterFetch()
}
sim.error = function(){
console.log("no SIM card detected")
sim.afterFetch()
}
return sim
})()
|