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

huangapple go评论89阅读模式
英文:

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

问题

我正在尝试使用Firebase Admin SDK 7.0.0在Java中设置向浏览器发送Web推送消息。

在Firebase控制台的代码片段中(以及我在网上找到的一些示例中),它们使用了已弃用的构造函数:

FirebaseOptions options = new FirebaseOptions.Builder()
    .setCredentials(GoogleCredentials.fromStream(serviceAccount)).build();
英文:

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

得分: 1

经过深入研究(因为差异非常微小),我在官方文档中找到了解决方案,我想与您分享:

使用链接:https://firebase.google.com/docs/reference/admin/java/reference/com/google/firebase/FirebaseOptions.Builder

用法:

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

实际上,FirebaseOptions.builder() 方法在内部使用了已弃用的构造函数... 但也许他们会在以后的版本中进行更改。

  /**
   * 创建一个空的构造器。
   *
   * @return 新的构造器实例。
   */
  public static Builder builder() {
    return new Builder();
  }
  /**
   * 构造一个空的构造器。
   *
   * @deprecated 请使用 {@link FirebaseOptions#builder()} 代替。
   */
  @Deprecated
  public Builder() {}

希望能够有所帮助。

英文:

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

huangapple
  • 本文由 发表于 2020年9月24日 01:25:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/64033247.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定