简体   繁体   English

是否可以在 android/iOS 中向 FCM 通知添加图像图标?

[英]Is it possible to add an image icon to FCM notification in android / iOS?

Is it possible to add an image as icon in the notification tray using the java firebase API?是否可以使用 java firebase API 在通知托盘中添加图像作为图标? I have a spring boot backend and this is how I build the AndroidConfig:我有一个 Spring Boot 后端,这就是我构建 AndroidConfig 的方式:

    private AndroidConfig getAndroidConfig(String topic) {
        return AndroidConfig.builder()
            .putData("image", "url-to-image")
            .setTtl(Duration.ofMinutes(2).toMillis()).setCollapseKey(topic)
            .setPriority(AndroidConfig.Priority.HIGH)
            .setNotification(AndroidNotification.builder().setSound("default")
                .setColor("#FFFF00").setTag(topic).build()).build();
    }

but there is no image here in the notification tray:但通知托盘中没有图像:

在此处输入图片说明

Is it even possible to do this with the java API?甚至可以使用 java API 来做到这一点吗?

Looking at AndroidNotification.builder it has a setImage method ( https://firebase.google.com/docs/reference/admin/java/reference/com/google/firebase/messaging/AndroidNotification.Builder.html#setImage(java.lang.String) that should do the trick.查看AndroidNotification.builder它有一个setImage方法( https://firebase.google.com/docs/reference/admin/java/reference/com/google/firebase/messaging/AndroidNotification.Builder.html#setImage(java.lang .String)应该可以解决问题。

I've only created FCM notifications in node, but the notification builder looks similar to the payload I send in node to include images.我只在 node 中创建了 FCM 通知,但通知构建器看起来类似于我在 node 中发送的有效负载以包含图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM