Web push messages to browser in Java FirebaseOptions.Builder() @Deprecated (firebase-admin SDK 7.0.0)

Viewed 280

I'm trying to setup a sending web push messages to browsers in java, with firebase-admin sdk 7.0.0

In the firebase console code snippet (and also in some example I found online), they use the deprecated constructor

FirebaseOptions options = new FirebaseOptions.Builder()
    .setCredentials(GoogleCredentials.fromStream(serviceAccount)).build();
1 Answers

After a deep research (because the difference is very tiny) I found the solution in the official documentation I would like to share with you:

https://firebase.google.com/docs/reference/admin/java/reference/com/google/firebase/FirebaseOptions.Builder

Use:

FirebaseOptions options = FirebaseOptions.builder()    
    .setCredentials(GoogleCredentials.fromStream(serviceAccount)).build();

Actually the FirebaseOptions.builder() method use internally the deprecated constructor... but maybe they will change it in the next releases.

  /**
   * Creates an empty builder.
   *
   * @return A new builder instance.
   */
  public static Builder builder() {
    return new Builder();
  }
  /**
   * Constructs an empty builder.
   *
   * @deprecated Use {@link FirebaseOptions#builder()} instead.
   */
  @Deprecated
  public Builder() {}

hope can be usefull

Related