- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我只是想从我的新 firebase-admin SDK 的 Java 代码中解决弃用说明,该代码是在版本 5.3.1 中编写的,但是在将版本升级到 5.5.0 后出现了弃用说明,这是一个我的代码示例:
使用 FirebaseAuth(弃用:Task
、addOnSuccessListener
和 addOnFailureListener
):
private CompletableFuture<FirebaseToken> getDecryptedTokenCompletableFuture(String firebaseTokenString) {
CompletableFuture<FirebaseToken> tokenFuture = new CompletableFuture<>();
Task<FirebaseToken> tokenTask = FirebaseAuth.getInstance(firebaseApp).verifyIdToken(firebaseTokenString);
tokenTask.addOnSuccessListener(tokenFuture::complete);
tokenTask.addOnFailureListener(exception -> tokenFuture.completeExceptionally(new AuthorizationException("Failed to verify token", exception)));
return tokenFuture;
}
对于 FirebaseDatabase(弃用:Task
、addOnSuccessListener
、addOnFailureListener
、updateChildren
和 removeValue
) :
public static <T> CompletableFuture<T> toCompletableFuture(Task<T> task) {
CompletableFuture<T> future = new CompletableFuture<>();
task.addOnCompleteListener(result -> {
future.complete(result.getResult());
}).addOnFailureListener(future::completeExceptionally);
return future;
}
/**
* @param updatedParams if null it will removed child
* @param path path to update
* @return void when complete
*/
public CompletableFuture<Void> updateObjectData(Map<String, Object> updatedParams, String path) {
if (updatedParams == null) {
return removeObjectData(path);
}
logger.debug("Update ObjectData in firebase of ref ({}) with data: {}", path, updatedParams.toString());
DatabaseReference child = this.getUserDataReference().child(path);
return toCompletableFuture(child.updateChildren(updatedParams));
}
/**
* @param path path to of node to remove
* @return void when complete
*/
public CompletableFuture<Void> removeObjectData(String path) {
logger.debug("Remove ObjectData in firebase of ref ({})", path);
DatabaseReference child = this.getUserDataReference().child(path);
return toCompletableFuture(child.removeValue());
}
弃用说明说我必须使用 ApiFuture
正如发行说明所说:https://firebase.google.com/support/release-notes/admin/java
内部源代码,例如:
/**
* Similar to {@link #updateChildrenAsync(Map)} but returns a Task.
*
* @param update The paths to update and their new values
* @return The {@link Task} for this operation.
* @deprecated Use {@link #updateChildrenAsync(Map)}
*/
和
/**
* Represents an asynchronous operation.
*
* @param <T> the type of the result of the operation
* @deprecated {@code Task} has been deprecated in favor of
* <a href="https://googleapis.github.io/api-common-java/1.1.0/apidocs/com/google/api/core/ApiFuture.html">{@code ApiFuture}</a>.
* For every method x() that returns a {@code Task<T>}, you should be able to find a
* corresponding xAsync() method that returns an {@code ApiFuture<T>}.
*/
最佳答案
使用 ApiFuture 从 Firebase Admin SDK Java 中使用 FirebaseAuth 验证 token 的代码是:
ApiFutures.addCallback(FirebaseAuth.getInstance().verifyIdTokenAsync(token),
new ApiFutureCallback<FirebaseToken>() {
@Override
public void onFailure(Throwable t) {
// TODO handle failure
}
@Override
public void onSuccess(FirebaseToken decodedToken) {
// TODO handle success
}
});
可以对使用 FirebaseDatabase 的代码使用类似的方法。
Hiranya Jayathilaka 写了一篇非常详细的文章,解释了如何从 Task 迁移到 ApiFuture 及其背后的原理:https://medium.com/google-cloud/firebase-asynchronous-operations-with-admin-java-sdk-82ca9b4f6022
此代码适用于版本 5.4.0 - 5.8.0,这是撰写本文时的最新版本。发行说明可在此处获得:https://firebase.google.com/support/release-notes/admin/java
关于java - 如何从弃用的任务转移到 ApiFuture for firebase admin SDK 5.4 及更高版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47412221/
我只是希望我所有的管理页面都在 /admin 下. 我的主页在 /admin但是当我单击侧栏中的用户时,它会将路径更改为 /users而不是 /admin/users . 我正在使用 rea
我在端口 8011 上设置了一个 Django 服务器,并在端口 80 上有一个 nginx 作为子目录服务。 静态文件,不错。 页面,很好。 但是当我访问/subdirectory/admin/时,
我正在尝试使用 Flask 和 Flask-SuperAdmin 自定义我的 Admin View ,但是,索引 View 和 subview 显然没有使用相同的 is_accessible 方法:
我正在尝试配置我的 .htaccess,以便当有人导航到路径 /wp-admin/admin.php?page=something 时,路径 /wp-admin/something显示在浏览器中,内容
有没有办法整体禁用分页?我希望我的所有记录都显示在一个长列表中,而不是分成几页。我现在正在使用 ListGuesser,我已经尝试过 List 和 ListGuesser,但我无法禁用分页。实际上 r
在本地部署时,我的 RA 项目呈现良好,但是,当我将构建目录复制到 S3 存储桶进行部署时,它呈现的一切都一团糟。有时它有效,但大多数时候它呈现如下图所示。它在带有 AOR 的两种环境中都能正常工作。
我试图在 Datagrid 中显示Field这是多对多关系(中间表)。 我有这些表: 组 - group_subject - 主题 一个小组可以有多个科目 一个主题可以连接多个群组 group_sub
在用于显示用户列表的 Django 管理屏幕中(带有标题,选择要更改的用户),有用户名/电子邮件等字段和员工状态。我想将用户的事件状态添加到该显示中。 尽管大多数 django-admin 自定义问题
无论如何要检查所有 firebase 事务是否在 firebase-admin nodejs 脚本中完成,并正确断开与 firebase 的连接并退出 nodejs 脚本? 目前,即使在所有事务完成后
我正在尝试使用 react-admin 将数据发送到我的自定义 API。我想发送文件,我可以看到有,我想将该数据作为多部分表单数据发送。我遇到过the base64 encoding help pag
我正在尝试在admin部分中实现带有子表单的表单。 form = Fighter() subform = FighterFightHistory() //All of his fights 我的问题如
我在编辑表单中获取记录的“更新”值时遇到了很大的麻烦。我总是得到初始记录值,即使我有一个链接到正确记录源的输入,它应该更新它。 有没有其他方法来获取 SimpleForm 的值? 我有一个简单的编辑表
开发一个不需要翻译的管理员。有没有办法完全关闭它们。就像现在一样,对于诸如通知之类的事情,它们会显示,但我也会收到有关缺少翻译键的控制台警告。 最佳答案 除了 Frederik 的回答之外,以下是禁用
开发一个不需要翻译的管理员。有没有办法完全关闭它们。就像现在一样,对于诸如通知之类的事情,它们会显示,但我也会收到有关缺少翻译键的控制台警告。 最佳答案 除了 Frederik 的回答之外,以下是禁用
我有这样的模型: class User(db.Model): __tablename__ = 'users' __table_args__ = {'mysql_engine' : 'I
我已经使用 Media 类自定义了我的内联模型。 我想自定义内联字段集以实现两件事: 为每一行添加一个按钮 按下“添加新行”时从 javascript 代码运行 我试过覆盖 tabular.html
我的所有管理员/任何 url 正在呈现管理文件,但是当我尝试只点击管理员时,它显示 404 不在这条路线上。我可以为 url/admin 创建单独的路由,但这是他们的任何其他选项。这样我只能通过单一路
虽然我使用了许多图表,如 HighCharts、Charts.js、C3、D3,但是否有人尝试过或是否有一些关于如何将任何图表框架包含在 React-admin 中的文档?我看了一些,但看起来我们必须
react-admin 文档将资源的默认路由解释为: /posts/:id 映射到 PostEdit /posts/:id/show 映射到 PostShow 我希望我的应用程序默认为查看,并且仅当用
我正在使用 react-admin 前端框架,想知道是否有办法从路由中删除“#”。我正在使用 customRoutes 属性为我们的系统提供路由集合。 ``` 最佳答案 您可以创建自己的历
我是一名优秀的程序员,十分优秀!