You can implement this:
On the server, in the database create a table with devices. Fields:
id (auto)tokendevice_id (unique device identifier obtained when logging in from it)last_login (last login time from this device)user_id (link to user table)
device_id can be obtained on the device as follows:
public static String getUniqueID(Context context) { //получаем IMEI TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String uniqueID = telephonyManager.getDeviceId(); if (uniqueID != null) { return uniqueID; } if (android.os.Build.VERSION.SDK_INT >= 9) { //если Android OS >=2.3 - то получаем уникальный серийный номер устройства uniqueID = android.os.Build.SERIAL; } if (uniqueID != null) { return uniqueID; } //получаем уникальный идентификатор Android (при сбросе системы может меняться) uniqueID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); return uniqueID; }
In requests to the server, send token and device_id . On the server to check compliance.
The last_login field last_login necessary for periodic cleaning of the database. For example, if a month did not go in from this device (conditional time), delete it.