# Register a device

To register a new device you'll need to have a Firebase token, which you can obtain one from your `FirebaseMessagingService` method `onNewToken`:

```java
@Override
public void onNewToken(String token) {
}
```

Then is the best practice to register your device calling the registration API:

```java
@Override
public void onNewToken(String token) {
    MBurgerPushTasks.sendToken(getApplicationContext(), 
            listener, //OPTIONAL LISTENER FOR TOKEN SENDING AND ERROR MANAGING
            getDeviceID(), token);
}
```

Where `getDeviceID()` is your method to obtain the **Android ID** which will be your unique identifier. Pay attention to the changes Oreo makes to this data, refer to [this documentation](https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID). Now your device is ready to receive push messages with your `FirebaseMessagingService` method `onMessageReceived`, but if you need to differentiate push groups you may need to use **topics**.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mpush.cloud/android-sdk/register-a-device.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
