在 android 中使用 JSONObject 通过 "extra information" 发送 Firebase API 通知

Send Firebase API Notification with "extra information" using JSONObject in android

我正在开发一个 android 应用程序,我正在使用 Firebase API 在 android studio 中使用 HTTP POST 发送推送通知。我按照教程 here 发送标题和 body。它工作正常。我想发送额外的信息,请建议我如何实现?。这是我的代码:

            ...

            JSONObject json = new JSONObject();                                                                     
            json.put("to", "/topics/" + "Greetings");

            JSONObject info = new JSONObject();
            info.put("title", "Hi");
            info.put("body", "Good morning");
            json.put("notification",info);

            JSONObject data = new JSONObject();
            data.put("extra_information", PreferenceUtils.getUserID());
            json.put("extra_information", data);

            ...

Firebase json 负载如下所示:

[
    "to" => 'DEVICE_TOKEN',
    "notification" => [
        "body" => "SOMETHING",
        "title" => "SOMETHING",
        "icon" => "ic_launcher"
    ],
    "data" => [
        "ANYTHING EXTRA HERE"
    ]
]

额外使用以下内容。

JSONObject extras = new JSONObject();
extras.put("message", "Happy birthday!");
extras.put("userId", PreferenceUtils.getUserID());
json.put("data",extras);