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

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

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

  1. FirebaseOptions options = new FirebaseOptions.Builder()
  2. .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

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

答案1

得分: 1

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

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

用法:

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

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

  1. /**
  2. * 创建一个空的构造器。
  3. *
  4. * @return 新的构造器实例。
  5. */
  6. public static Builder builder() {
  7. return new Builder();
  8. }
  1. /**
  2. * 构造一个空的构造器。
  3. *
  4. * @deprecated 请使用 {@link FirebaseOptions#builder()} 代替。
  5. */
  6. @Deprecated
  7. 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:

  1. FirebaseOptions options = FirebaseOptions.builder()
  2. .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.

  1. /**
  2. * Creates an empty builder.
  3. *
  4. * @return A new builder instance.
  5. */
  6. public static Builder builder() {
  7. return new Builder();
  8. }
  1. /**
  2. * Constructs an empty builder.
  3. *
  4. * @deprecated Use {@link FirebaseOptions#builder()} instead.
  5. */
  6. @Deprecated
  7. public Builder() {}

hope can be usefull

huangapple
  • 本文由 发表于 2020年9月24日 01:25:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/64033247.html
  • deprecation-warning
  • firebase
  • firebase-cloud-messaging
  • java
  • web-push

如何检查Class是否可转换为类。 go 107
匿名

发表评论

匿名网友

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

确定

  • 开发者交流平台

    本页二维码