How to identify if device token is for android or iOS?

前端 未结 5 1868
孤街浪徒
孤街浪徒 2021-01-12 11:57

I store Android and iOS device tokens in DB. Following are few examples of device tokens getting saved in the DB.

  • 359092050465370
  • 654C4DB3-3F68-4969-8
5条回答
  •  北海茫月
    2021-01-12 12:24

    To get IMEI (international mobile equipment identifier) :

    public String getIMEI(Activity activity) {
        TelephonyManager telephonyManager = (TelephonyManager) activity
                .getSystemService(Context.TELEPHONY_SERVICE);
        return telephonyManager.getDeviceId();
    }
    

    To get device unique id :

    public String getDeviceUniqueID(Activity activity){
        String device_unique_id = Secure.getString(this.getContentResolver(),
                Secure.ANDROID_ID);
        return device_unique_id;
    }
    

提交回复
热议问题