【发布时间】:2018-03-07 08:12:04
【问题描述】:
根据here 和here,FCM 支持在使用 FCM REST API 时将 mutable_content 变量作为布尔值发送。但我在 Firebase Admin Java API 中找不到等效方法。
final ApsAlert alert = ApsAlert.builder()
.setTitle("Test notification")
.setBody("Hello World")
.build();
final Aps aps = Aps.builder()
.setAlert(alert)
.setBadge(messageCount)
.setContentAvailable(messageCount > 10000)
.setCategory("tesy")
.build();
final ApnsConfig config = ApnsConfig.builder()
.putHeader("apns-id", getMessageId())
.setAps(aps)
.putCustomData("type", "test")
.putCustomData("mutable_content", true)
.build();
remoteMessage.setApnsConfig(config);
尝试将其设置为ApnsConfig中的自定义数据值,但不起作用。
PS:此方法运行在 Spring Boot 服务器中,用于向用户发送通知。
【问题讨论】:
-
我相信密钥被命名为
mutable-content(用连字符代替下划线),并且应该设置为Aps。当前的 API 不支持此功能。你能提交一个功能请求吗? -
@HiranyaJayathilakaas 根据 Firebase 文档 (firebase.google.com/docs/cloud-messaging/…),当直接通过 API 调用发送时,它在 Firebase 中应该是
mutable_content。这就是我使用mutable_content的原因。我试过mutable-content也没有用。我将为此提出功能请求 -
您链接到的文档是指旧版 FCM API。 Java SDK 使用
v1API,应将其指定为mutable-content。但是现在 Java API 没有公开它,所以不管怎样都没有关系。如果您要直接使用 Node.js SDK 或 REST API,您可能可以设置此选项。
标签: ios firebase apple-push-notifications firebase-cloud-messaging firebase-admin