android - OneSignal - 使用来自 url 的自定义图像从 android 应用程序发送通知
问题描述
我有一个问题:如何使用带有自定义图像 url 的 onesignal 自定义从我的 android 应用程序发送的通知?
我应该发送如下图所示的通知:
如果我发送没有自定义图像 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 文档中的说明使用。
例子:large_icon:"https://website.com/path/to/resource.jpg"
推荐阅读
- php - Laravel 路线中未识别路线
- matplotlib - Matplotlib:具有相同布局的多个图(无自动布局)
- android - 未解决的参考 MergeAdapter
- sql - 父子层次结构的根父级
- css - 在百分比宽度容器之外展开图像
- mysql - 如何在 MySQL 外键上覆盖数据库
- c++ - 如何获得二维向量的第一层索引?
- r - 在 DictionaryLearner 中找不到键为“surv.xgboost”的元素
- android - 为什么我的android studio 4.0 项目结构不同?
- swift - 来自字符串的 Swift URL,其中包含 `caffè`