android - OneSignal - 使用来自 url 的自定义图像从 android 应用程序发送通知

标签 android firebase push-notification google-cloud-firestore onesignal

我有一个问题:如何使用带有自定义图像 url 的 onesignal 自定义从我的 android 应用程序发送的通知?

我应该发送如下图所示的通知:

Notification

如果我发送一个没有自定义图片 url 的基本通知就没问题。 我在我的 android 应用程序中编写了这个 json 以将请求发送到 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\"}"
    + "}";

必须如何修改上面的 JSON 才能将图像添加到通知中?

提前致谢

最佳答案

您需要使用 large_icon,如 REST API docs 中所示.

示例:large_icon:"https://website.com/path/to/resource.jpg"

关于android - OneSignal - 使用来自 url 的自定义图像从 android 应用程序发送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56110017/

相关文章:

java - 如何在 Android/Java 中读取 Apache POI 中的 xlsx 文件

javascript - 无法使用 Firebase Messaging 编译 React Native 应用程序?

android - 是否必须将 Google Map api V1 更改为 V2

firebase - 如何减少 Firebase Cloud Firestore 上的读取操作?

ios - 收到推送通知时捕获

android - android pushwoosh他方法'java.io.File android.support.v4.content.ContextCompat

java - 无法解析方法 getlatitude()

firebase - Android Firebase 数据库存储大小限制

javascript - stripe firebase 可调用函数返回 null

android - Azure 通知中心仅向 iOS 发送通知