2016年2月23日 星期二

Android 開發 (113) Best Practices for Unique Identifiers

最近在逛android developer的時候,無意間發現了這個頁面
http://developer.android.com/intl/zh-tw/training/articles/user-data-ids.html
裡面說明了各種用來辨識user的情境,以及可以用什麼資料來判斷才是正確的解法,


舉例來說,以前我們總是利用
//Returns the unique device ID, for example, the IMEI for GSM and the MEID or ESN for CDMA phones.

TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String id = tm.getDeviceId();


或者是Android ID
id = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);


如今google 推薦可以使用mac address,但是必須使用官方的取得方式才行
如下


裡面還有提了如何預防DDOS的方法


不過似乎是android 限定
http://developer.android.com/intl/zh-tw/training/safetynet/index.html



利用api 取得JwsResult之後,假設 ctsProfileMatch = true
代表驗證成功,接著還必須利用api 再次驗證資料無誤,才算認證成功



上面的連結其實還提供了很多相關的情境,歡迎大家在實作的時候可以拿去參考

沒有留言:

張貼留言