Hi, in addition to Salil's answer. I would suggest using Android_Id since you don't need any additional permission for that,
String m_androidId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
However, sometimes you might have some trouble with having unique Ids. The Id may change on factory reset, flash and rooting of devices.
And for ios you could use UUID
instead of UDID.
Hope this helps!