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:

@Override
public void onNewToken(String token) {
}

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

@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. 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.

Last updated