/var/log

Firebase Cloud Messaging without google-services.json file

The default way to initialize Firebase in your Android app is to use the google-services.json file you can download from the firebase console. The content of this file will be automatically merged by gradle to initialize the FirebaseApp instance for your app.

To manually initialize a FirebaseApp app, you can do the following (I replaced the real values with the key structure of the google-services.json file):

FirebaseOptions options = new FirebaseOptions.Builder()
  .setApiKey("client.api_key.current_key")
  .setApplicationId("client.client_info.mobilesdk_app_id")
  .setDatabaseUrl("project_info.firebase_url")
  .setGcmSenderId("project_info.project_number").build();

FirebaseApp app = FirebaseApp.initializeApp(getApplicationContext(), options);

String token = FirebaseInstanceId.getInstance().getToken();
Tag: | Category: