博览会组通知

时间:2018-09-10 14:37:38

标签: java android push-notification notifications expo

我正在使用EXPO通知。 其从JAVA发送的工作帖子如下:

public class post {

private final String USER_AGENT = "Mozilla/5.0";

public static void main(String[] args) throws Exception {

    post http = new post();


    System.out.println("\nTesting 2 - Send Http POST request");
    http.sendPost();

}

// HTTP POST request
    private void sendPost() throws Exception {

        String url = "https://exp.host/--/api/v2/push/send";
        URL obj = new URL(url);
        HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();

        //add request header
        con.setRequestMethod("POST");
        con.setRequestProperty("User-Agent", USER_AGENT);
        con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");

        String urlParameters = "to=ExponentPushToken[xxxxx-xx]&title=Title of the Notification&body=Body of your Notification";

        // Send post request
        con.setDoOutput(true);
        DataOutputStream wr = new DataOutputStream(con.getOutputStream());
        wr.writeBytes(urlParameters);
        wr.flush();
        wr.close();

        int responseCode = con.getResponseCode();
        System.out.println("\nSending 'POST' request to URL : " + url);
        System.out.println("Post parameters : " + urlParameters);
        System.out.println("Response Code : " + responseCode);

        BufferedReader in = new BufferedReader(
                new InputStreamReader(con.getInputStream()));
        String inputLine;
        StringBuffer response = new StringBuffer();

        while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
        }
        in.close();

        //print result
        System.out.println(response.toString());

    }

}

问题是,我如何一次发送多个通知。如果我发送通知,则执行“ X”和“ Y”,我希望它位于同一通知中,而不是分开。

0 个答案:

没有答案