1066
Views
12
Comments
Solved
Get IMEI number
Question

Hi,


how can I get IMEI no of mobile device ?


thanks.

2016-11-20 11-27-52
João Neves
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

2018-09-22 14-36-02
Kurt Vandevelde
 
MVP
2017-06-27 15-30-33
tBt

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

2016-11-20 11-27-52
João Neves
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

2017-06-27 15-30-33
tBt

Hi Joao,


tq, the Imei working now. 

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

2016-11-20 11-27-52
João Neves

Usually cordova callbacks are async.

2017-06-27 15-30-33
tBt

Ic, ok thanks.

2017-06-27 15-30-33
tBt

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  ?

2016-11-20 11-27-52
João Neves

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

2017-06-27 15-30-33
tBt

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' ...


2017-06-27 15-30-33
tBt

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).

2016-11-20 11-27-52
João Neves

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);
    }
);
2017-06-27 15-30-33
tBt

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.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.