NonCollapse Image FCM using Java

18 views Asked by At
if ((priority.equals("HIGH") || priority.equals("NORMAL")) && collapse_state.equals("collapse")) {
        log.info("if priority :" + priority + " collapse_state :" + collapse_state);
        androidConfBuilder = AndroidConfig.builder()
                .setTtl(300 * 1000) // 1 hour in milliseconds
                .setPriority(priority.equals("HIGH") ? AndroidConfig.Priority.HIGH : AndroidConfig.Priority.NORMAL)
                .setCollapseKey(collapseId) // Set collapse key
                .setNotification(AndroidNotification.builder()
                        .setIcon("stock_ticker_update")
                        .setColor("#f45342")
                        .setImage(img) // Set image
                        .build());
    } else if ((priority.equals("HIGH") || priority.equals("NORMAL")) && collapse_state.equals("nonCollapse")) {
        log.info("else if priority :" + priority + " collapse_state :" + collapse_state);
        androidConfBuilder = AndroidConfig.builder()
                .setTtl(300 * 1000) // 1 hour in milliseconds
                .setPriority(priority.equals("HIGH") ? AndroidConfig.Priority.HIGH : AndroidConfig.Priority.NORMAL)
                .setNotification(AndroidNotification.builder()
                        .setIcon("stock_ticker_update")
                        .setColor("#f45342")
                        .setImage(img) // Set image
                        .build());
    }

I've developed a service for sending FCM (Firebase Cloud Messaging) notifications containing images to users. The service supports both collapse and non-collapse behaviors. However, I'm encountering an issue where the image is displayed when the notification collapses, but it fails to display when the notification doesn't collapse. I've thoroughly reviewed the official Firebase documentation, but couldn't find any information addressing this specific problem. Could someone please assist me in resolving this issue? Any insights or suggestions would be greatly appreciated.

0

There are 0 answers