Get IMEI number

  

Hi,


how can I get IMEI no of mobile device ?


thanks.

Hi, I've tried it but it only returns empty string. maybe how i use it is wrong ?

Solution

Hi Tobit,

Try the following:

window.plugins.imeiplugin.getImei(function (imei) {
    $parameters.IMEI = imei;
    $resolve();
});

The use of callbacks impose an asynchronous programming model, thus you have to use the $resolve implicit function to tell the platform that this is an async block of code. Check out this article for more details: https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/JavaScript/Extend_Your_Mobile_App_Using_JavaScript/Defining_Asynchronous_JavaScript_Code

Solution

Hi Joao,


tq, the Imei working now. 

Just curious, how you know that this is an async block code ?

Usually cordova callbacks are async.

Ic, ok thanks.

Hi Joao,


just now when I m testing apps, my app is stuck when getImei action is called.

I tried to remove $resolve() from the plugin, and it's ok now.

can you help me to identify what is the cause  ?

Probably its throwing an error, but since the plugin doesn't have an error callback its not possible to understand the cause. I recommend that you try another plugin: https://github.com/pbakondy/cordova-plugin-sim

hi Joao,


I'm confused how to use it. my javascript skill is a bit sucks :(

btw, i tried it like this, but it returns an error : "cannot assign a javascript object with value [object Object] to an output parameter of type Text. Check the javascript node 'Javascript1' ...


I realized something. I tried to make again a new application with this imei plugin.

https://github.com/zho/phonegap-imeiplugin.git

at the first, it worked, but second time I login, the same symtomp appeared (stuck).

Regarding you previous attempt the info parameter is an object, so try do the following

window.plugins.sim.getSimInfo(
    function (info) {
        $parameters.IMEI = info.deviceId;
        $resolve();
    },
    function (error) {
        $reject(error);
    }
);

i think the plugin doesn't work, it return empty string.

After discussed with my team, we decided to use UUID instead.

tq for your help Joao.