英文:
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:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论