Search code examples
androidcordovaionic2cordova-pluginsimei

how to get IMEI number in ionic 2 mobile app?


I am building a mobile application and want to access the IMEI number.

I have gone through the following plugins.

  1. https://github.com/vliesaputra/DeviceInformationPlugin
  2. https://github.com/hygieiasoft/cordova-plugin-uid
  3. https://github.com/aquto/cordova-plugin-imei

And all of them are giving me 404 error.

Finally I got one plugin that I could install

  1. https://www.npmjs.com/package/imeiplugin

and below is the code I wrote to access the IMEI

The below code is written inside my home constructor.

platform.ready().then(() => {
            window["plugins"].imeiplugin.getImei(function (imei) {
                console.log(imei);
            });
        });

But the control never goes to the console.log();

Am I doing anything wrong here??

Or if anyone has integrated the IMEI number with some other method please let me know.

Or as per suggested in the below link do I have to build my own custom plugin??

  1. How to get IMEI number in PhoneGap?

I am stuck here and I am looking for an efficient way any help is appreciated.

Thanks in advance


Solution

  • Actually this plugin works: https://github.com/hygieiasoft/cordova-plugin-uid

    (Using: cordova plugin add org.hygieiasoft.cordova.uid returns 404)

    So try this instead: cordova plugin add https://github.com/hygieiasoft/cordova-plugin-uid

    platform.ready().then(() => {
       alert(cordova.plugins.uid.IMEI);
    });