Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i get my registration ID device

What do I need to send a push notification for android (like iOS I need a device udid to send a simple push)?

And if I need to get the registration id of my device how can i get it?

Thank you.

like image 726
abdel Avatar asked May 30 '12 08:05

abdel


People also ask

What is device registration ID?

An ID generated by the FCM SDK for each client app instance. Required for single device and device group messaging. Note that registration tokens must be kept secret.

How do you register your device?

To register a new device: Tap the menu icon. Tap anywhere in the section containing your name and profile picture. Tap DEVICES. Tap on Register Device.


1 Answers

Do you need this?

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;
}
like image 74
Bobs Avatar answered Oct 01 '22 16:10

Bobs