-1

I have initialised firebase in android without using the google-services plugin like this

FirebaseOptions.Builder builder = new FirebaseOptions.Builder()
                        .setApplicationId("application-id")
                        .setApiKey("api-key")
                        .setDatabaseUrl("database-url")
                        .setStorageBucket("storage-bucket")
                        .setProjectId("project-id")
                        .setGcmSenderId("gcm-sender-id");
                FirebaseApp.initializeApp(context,builder.build());

Now after initialising the firebase app how can i get the token generated to send push notification via FCM

iqbalpalemad
  • 77
  • 1
  • 2
  • 10
  • See https://stackoverflow.com/questions/37787373/firebase-fcm-how-to-get-token, https://stackoverflow.com/questions/51123197/firebaseinstanceidservice-is-deprecated and https://firebase.google.com/docs/cloud-messaging/android/client#retrieve-the-current-registration-token – Frank van Puffelen Apr 29 '19 at 14:22

1 Answers1

2

I think you could get it like:

 FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(instanceIdResult -> {
            String token = instanceIdResult.getToken();
            updateToken(token, apiService, sessionManager); // update token on server
        });
Djek-Grif
  • 1,391
  • 18
  • 18