【问题标题】:OneSignal - Send a notification from android app with a custom image from urlOneSignal - 使用来自 url 的自定义图像从 android 应用发送通知
【发布时间】:2019-05-13 10:00:28
【问题描述】:

我有一个问题:如何使用带有自定义图像 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 必须如何修改才能将图像添加到通知中?

提前致谢

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-12
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      • 2018-06-24
      • 2018-01-22
      • 1970-01-01
      相关资源
      最近更新 更多