Get IMEI number of device on Android using NativeScript

There was a small project I did which required the IMEI number to be read. I used the following code to read the IMEI number on Android using NativeScript.


<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

NativeScript code

function getIMEI(){
    var context =;
    var tm = context.getSystemService(android.content.Context.TELEPHONY_SERVICE);
    return tm.getDeviceId()

Then call getIMEI() where there is a need. Simple.