2012-05-30 67 views
9

我需要发送一个推送通知为Android(如iOS我需要一个设备udid发送一个简单的推送)?我怎样才能得到我的注册ID设备

如果我需要获得我的设备的注册ID我怎么能得到它?

谢谢。

+0

您只能发送设备ID,而不是注册ID。 – Aerrow

+0

我试着用注册ID,它的工作,但我没有找到如何发送与设备ID推送通知。所以你有一个链接? – abdel

回答

1

你需要这个吗?

public static String getDeviceID(Context context) { 
    final TelephonyManager tm = (TelephonyManager) context 
      .getSystemService(Context.TELEPHONY_SERVICE); 

    final String tmDevice, tmSerial, tmPhone, androidId; 
    tmDevice = "" + tm.getDeviceId(); 
    tmSerial = "";// + tm.getSimSerialNumber(); 
    androidId = "" 
      + android.provider.Settings.Secure.getString(
        context.getContentResolver(), 
        android.provider.Settings.Secure.ANDROID_ID); 

    UUID deviceUuid = new UUID(androidId.hashCode(), 
      ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode()); 
    String deviceId = deviceUuid.toString(); 

    return deviceId; 
}