在网络应用程序的Andr​​oid / iPhone设备上数据的区别? [英] Android/Iphone device data distinction in web-application?

查看:118
本文介绍了在网络应用程序的Andr​​oid / iPhone设备上数据的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我工作的一个Web应用程序这将有它的Andr​​oid和iPhone应用程序开发也是数据库体系结构。

和的,我想创建 mysql数据库列名 DEVICE_ID 来跟踪,如果用户是使用通过应用程序的 web应用程序 Android的应用程序 iPhone应用内

下面是几个官能几点:

创建/注册

  • 可以通过web应用程序/ Android的应用程序/ iPhone应用程序内完成。

登录

  • 在何处并不重要用户创建已经完成的,用户可以从所有基于Web的中央数据库登录(使用登录Web服务)。

问题域

  

没有任何事实,但我的一些技术团队曾表示:

iPhone 机器人这将提供一个 UDID ANDROID_ID 早期是不会这么做的未来的版本。

现在,

移动应用程序的工作,即使没有互联网连接,所以我制定了关于将同步在设备中的数据与Web相同的同步工具网络到设备在点击一个按钮。

某些情况下,可以包括的相同的用户,谁在使用从各种设备和web应用程序,以及使得数据获取同步的设备和网络无缝上。

因此​​,这将是最好的解决方法对于这一点,我能自动产生一些独特的序列,而不是依赖于设备上的ID为同步过程。

---编辑---

  

在恢复出厂设置,并植根设备及其确保设备不会   返回一个唯一的ID,也有各种各样的开发公司   工作的机器人的定制,因此它是不适合一个保证   唯一的设备ID。所以,我怎么能得到一个更好的解决办法被一些   逻辑在我结束和Web也。

解决方案

猜你与同步过程(@Nishant B的职位)的唯一ID做了,现在这里是code段为所有Android设备的工作原理差不多(Tab键+移动)。

现在你也知道,也不能保证在任何Android的唯一ID,以便其更好地创建这将产生的多重键和唯一在我们每次生成的时间相结合的关键...

  TelephonyManager TelephonyMgr =(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
串szImei = TelephonyMgr.getDeviceId(); //要求READ_PHONE_STATE

字符串m_szDevIDShort =35+ //我们让这个看起来像一个有效的IMEI
Build.BOARD.length()%10+ Build.BRAND.length()%10 +
Build.CPU_ABI.length()%10 + Build.DEVICE.length()%10 +
Build.DISPLAY.length()%10 + Build.HOST.length()%10 +
Build.ID.length()%10 + Build.MANUFACTURER.length()%10 +
Build.MODEL.length()%10 + Build.PRODUCT.length()%10 +
Build.TAGS.length()%10 + Build.TYPE.length()%10 +
Build.USER.length()%10; // 13位


WifiManager WM =(WifiManager)getSystemService(Context.WIFI_SERVICE);

BluetoothAdapter m_BluetoothAdapter = NULL; //本地蓝牙适配器
m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
串m_szBTMAC = m_BluetoothAdapter.getAddress();
字符串m_szWLANMAC = wm.getConnectionInfo()getMacAddress()。


字符串m_szLongID = m_szImei + m_szDevIDShort + m_szWLANMAC + m_szBTMAC;
//计算MD5
消息摘要M = NULL;
尝试 {
     米= MessageDigest.getInstance(MD5);
}赶上(抛出:NoSuchAlgorithmException E){
e.printStackTrace();
}

m.update(m_szLongID.getBytes(),0,m_szLongID.length());
//获取MD5字节
字节p_md5Data [] = m.digest();
//创建一个十六进制字符串
字符串m_szUniqueID =新的String();

的for(int i = 0; I< p_md5Data.length;我++){
        INT B =(0xFF的&放大器; p_md5Data [I]);
//如果是一个数字,要确保它有0前面的(正确填充)
如果(b将= 0xF的)m_szUniqueID + =0;
//添加一些字符串
     m_szUniqueID + = Integer.toHexString(B);
}

//十六进制字符串为大写
m_szUniqueID = m_szUniqueID.toUpperCase();
 

在这里,我们采取了IMEI,制造商委员会的细节,无线地址和蓝牙地址(不采取ANDROID_ID其变化时,恢复出厂设置)。随着这些关键的人能产生一个唯一的密钥( m_szUniqueID )与MD5的帮助下联合而成的。

我敢肯定,随着这上面你的帮助,可以生成一个唯一的密钥每次。

好点:

  • 在它不是连续发生的这意味着一台设备将只有一个ID和IE唯一相同的设备有所不同。
  • 在即使未注册的设备,即设备的工作没有IMEI号码。
  • 工作与平板电脑了。

So, I am working on the database architecture of a web application which would have its android and iphone apps developed also.

And for that I want to create a column name device_id in mysql database to track if a user is using the application via web-app or android-app or iphone-app.

Below are a few functional points :

Creation / Sign Up

  • Can be done by web-app / android-app / iphone-app.

Log In

  • Doesn't matter where the user creation has been done from , User can login from all based on the central database on web (using a login web service).

Problem Domain

Don't have any facts but some of my tech team has advised that:

Iphone and Android those would provide a UDID and ANDROID_ID earlier are not going to do so in the future releases.

Now,

The mobile app works even without the internet connection and hence I have developed a sync tool for the same which will sync the data on device to web and web to device on a button click.

Some cases may include same user, who is using the app from various devices and web as well so that the data gets in sync on the device and web seamlessly.

Hence, what would be the best work-around for this, could I auto generate some unique sequence and not rely on the device id's for the syncing process.

---Edit---

On factory reset and rooted device its sure that the device won't return a unique Id and also there are various development firms working on android customization and hence it is not a guarantee for a unique device id . So, how could I get a better workaround by some logic at my end and web also.

解决方案

Guessing you are done with sync process(@Nishant B's post), now for Unique ID here is the code snippet which works almost for all Android devices (Tab + Mobile).

Now as you know, there is no guarantee of any Unique ID in Android so its better to create a key which will generate as a combination of multiple key and Unique on every time we generate...

TelephonyManager TelephonyMgr = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String szImei = TelephonyMgr.getDeviceId(); // Requires READ_PHONE_STATE

String m_szDevIDShort = "35" + //we make this look like a valid IMEI
Build.BOARD.length()%10+ Build.BRAND.length()%10 +
Build.CPU_ABI.length()%10 + Build.DEVICE.length()%10 +
Build.DISPLAY.length()%10 + Build.HOST.length()%10 +
Build.ID.length()%10 + Build.MANUFACTURER.length()%10 +
Build.MODEL.length()%10 + Build.PRODUCT.length()%10 +
Build.TAGS.length()%10 + Build.TYPE.length()%10 +
Build.USER.length()%10 ; //13 digits


WifiManager wm = (WifiManager)getSystemService(Context.WIFI_SERVICE);

BluetoothAdapter m_BluetoothAdapter = null; // Local Bluetooth adapter
m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
String m_szBTMAC = m_BluetoothAdapter.getAddress();
String m_szWLANMAC = wm.getConnectionInfo().getMacAddress();


String m_szLongID = m_szImei + m_szDevIDShort + m_szWLANMAC + m_szBTMAC;
// compute md5
MessageDigest m = null;
try {
     m = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}

m.update(m_szLongID.getBytes(),0,m_szLongID.length());
// get md5 bytes
byte p_md5Data[] = m.digest();
// create a hex string
String m_szUniqueID = new String();

for (int i=0;i<p_md5Data.length;i++) {
        int b = (0xFF & p_md5Data[i]);
// if it is a single digit, make sure it have 0 in front (proper padding)
if (b <= 0xF) m_szUniqueID+="0";
// add number to string
     m_szUniqueID+=Integer.toHexString(b);
}

// hex string to uppercase
m_szUniqueID = m_szUniqueID.toUpperCase();

here we had taken IMEI, Manufacturer Board detail, Wifi address and Bluetooth address (not taking ANDROID_ID as its change when factory reset). with combinition of these key one can generate a Unique key(m_szUniqueID) with the help of MD5.

I'm sure with the help of this above you can generate a unique key everytime.

Good points:

  • Its not vary on consecutive generation on same device which mean one device will have only one ID and i.e. Unique.
  • Even work with non registered device i.e. device without IMEI numbers.
  • works with Tablet too.

这篇关于在网络应用程序的Andr​​oid / iPhone设备上数据的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆