Forum Xamarin.Forms

How to get the IMEI number

MostafaEl-AbadyMostafaEl-Abady USUniversity ✭✭


Is there a way to get the IMEI number from Xamarin Forms app?
for android and iOS.

Best Answer


  • MCvelMCvel USMember ✭✭✭

    hey mate, did this worked for you? I found that the iOS implementation it is not working anymore

    check the comments in here->

  • AnkushSharma.5312AnkushSharma.5312 USMember ✭✭
    edited June 2016


    Thanks :)

  • YkshLeoYkshLeo USMember ✭✭✭✭

    @AnkushSharma.5312 :

    For Android :

    API level 23 onward there is something like string GetDeviceId (int slotId)

    Refer :

  • seanydaseanyda GBMember ✭✭✭✭✭

    @YkshLeo So am I right in saying if we use the iOS solution the app will get rejected?

  • AnkushSharma.5312AnkushSharma.5312 USMember ✭✭
    edited June 2016


    Accoding to your above link,DeviceId(IMEI) and AndroidId are two different things?

    So,how to find out DeviceId(IMEI) of phone using Dependency Services in Xamarin.Forms?

  • AnkushSharma.5312AnkushSharma.5312 USMember ✭✭
    edited June 2016
            Android.Telephony.TelephonyManager mTelephonyMgr;
                return mTelephonyMgr.DeviceId;

    i tried using above code but TELEPHONY_SERVICE is giving compile time error?

  • AnkushSharma.5312AnkushSharma.5312 USMember ✭✭
    [assembly: Xamarin.Forms.Dependency(typeof(UniqueIdAndroid))]
    namespace UniqueId.Droid
        public class UniqueIdAndroid : IDevice
            public string GetIdentifier()
                Android.Telephony.TelephonyManager mTelephonyMgr;
                mTelephonyMgr = (Android.Telephony.TelephonyManager)Forms.Context.GetSystemService(Android.Content.Context.TelephonyService);
                return mTelephonyMgr.DeviceId;

    This is how you implement it.

  • DinashDinash INMember

    I am relatively new to Windows Development, can you let me know how you were able to access


  • LuisValenciaLuisValencia USMember ✭✭

    I read here that since ios7 reading the imei wont pass the app store?

  • DanielSantosDanielSantos USMember
            var tm = (TelephonyManager)GetSystemService(TelephonyService);
            String imeistring = null;
            imeistring = tm.DeviceId;
            idView = (TextView)FindViewById(Resource.Id.imeitxt);
            idView.Append("IMEI No:  " + imeistring );
  • MrLovaMrLova USMember ✭✭

    I get a hex string value like "70eab036c06faf7", is not the corect IMEI !

    do i have to convert them ?

  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    You are right...
    I wanted to query the IME in my App and store it in the central database...
    The AndroidID is also an unique ID, but unfortunately not the IMEI (and it also can't be converted to the "real" IME!
    Also the ACR.DeviceInfo plugin seems to return the AndroidID (instead of thee IMEI).

    The only way, I found, is over the telefonyManager and that needs the "bad" right READ_PHONE_STATE, that you have to handle your own in your app (thanks to changes in Android marshmallow (Android 6).
    I have a shared .forms (3.1) App (whereby I only use the Android App yet) and have implemented the code below.
    The code works, but the App then needs in adition the right READ_PHONE_STATE, that you have to handle completely yourself in your app.
    As a correct and user-friendly handling is not easy to implement and needs a lot of additional effort, I dont use that for now (as I don't need it mandatory yet).

    if ANDROID
    // Needs Right READ_PHONE_STATE !! (else the app will crash) and you have to handle the rights in your app!
    var telephonyManager = (TelephonyManager)Forms.Context.GetSystemService(Android.Content.Context.TelephonyService);
    var IMEI = telephonyManager.DeviceId; // Example: “356457091758419” = This is the correct IMEI


  • MAJosephMAJoseph Member ✭✭

    @FredyWenger It shows an error . I've attached the screenshot. How can I resolve this problem ???

  • JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭
  • MAJosephMAJoseph Member ✭✭

    @JamesLavery Yeah It's working. Thanks for your help.

Sign In or Register to comment.