根据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引导服务器中运行,以将通知发送给用户。
答案 0 :(得分:2)
我也在搜索其他网站,最后,我得到了正确的输出(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();
在此代码中,我们还传递自定义数据。