It looks like you're new here. If you want to get involved, click one of these buttons!
function createID() local lang = application:getLanguage() local device = application:getDeviceInfo() local accel_present = Accelerometer.isAvailable() local gyroscope_present = Gyroscope.isAvailable() local geolocation_present = Geolocation.isAvailable() local screen_density = application:getScreenDensity() if screen_density == nil then screen_density = 0 end local id = string.format("%08x%03x%04x%04x%03x%x%x%x%x%x%x%x", os.time(), application:getFps(), application:getDeviceWidth(), application:getDeviceHeight(), screen_density, string.byte(lang, 1), string.byte(lang, 2), string.byte(device, 1), string.byte(device, 2), accel_present and 1 or 0, gyroscope_present and 1 or 0, geolocation_present and 1 or 0) return(id) end |
Comments
PRO: it is simple and cross platform as long as you can store files (will fail on HTML5 private mode).
CONS:
- id is lost if user reinstall the app
- id is different per device
- there is a (unlikely) risk of collision during generation