根据here和here,当使用FCM REST API时,FCM支持将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服务器上运行,将通知发送给用户。
发布于 2020-04-06 12:25:13
我也在搜索不同的网站,最后,我得到了适当的输出(IOS)
final ApsAlert alert =
ApsAlert.builder()
.setTitle(notification.getEventType())
.setBody(notification.getEventDescription())
.build();
final Aps aps =
Aps.builder()
.setAlert(alert)
.setContentAvailable(true)
.setMutableContent(false)
.build();
final ApnsConfig apnsConfig =
ApnsConfig.builder()
.setAps(aps)
.putCustomData("eventId", notification.getEventNumber())
.putCustomData("category", notification.getCategory())
.putCustomData("priority", notification.getEventPriority())
.build();
message =
Message.builder()
.setToken(notificationRequestDto.getTo())
.setApnsConfig(apnsConfig)
.build();在这段代码中,我们还传递了自定义数据。
https://stackoverflow.com/questions/49147002
复制相似问题