I have a question: how can I customize a notification sent from my android app using onesignal with a custom image url?

I should send a notification like the image below:


It's all ok if I sent a basic notification without custom image url. I composed this json in my android app to send the request to onesignal:

String strJsonBody = "{"
    + "\"app_id\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx\","
    + "\"filters\": [{\"field\": \"tag\", \"key\": \"firestoreUserId\", \"relation\": \"=\", \"value\": \"" + notificationBundle.getPost().getUserId() + "\"}],"
    + "\"data\": {\"postId\": \"" + notificationBundle.getPost().getId() + "\"" +
                    ",\"postDescription\": \"" + notificationBundle.getPost().getDesc() + "\"},"
    + "\"contents\": {\"en\": \"Hey, " + notificationBundle.getUser().getFullName() + " notification\"}"
    + "}";

How the JSON above must be modified to add an image to notification?

Thank's in advance


Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions