ページの先頭行へ戻る
Interstage Mobile Application Server V1.3.0 アプリケーション開発ガイド
FUJITSU Software

6.6.2 メッセージ送信アプリケーションの開発

メッセージ送信APIを利用することで、各プッシュサービスへ別々のメッセージを送信できます。

以下はメッセージ送信APIを呼び出す例です。
HttpClientBuilder httpclient = HttpClientBuilder.create();

String b64_authval = "1234567890abcdefghijklmnop==";
String url = "​https://ホスト名:ポート/pushidmng/notify";

StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append(" \"APNs\": {");
sb.append(" \"aps\": {");
sb.append(" \"alert\": \"test\",");
sb.append(" \"sound\": \"bingbong.aiff\",");
sb.append(" \"badge\": 7");
sb.append(" }");
sb.append(" },");
sb.append(" \"FJP\": {\"message\": \"fjp_message001\"},");
sb.append(" \"regIDs\": [");
sb.append(" \"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",");
sb.append(" \"12345678901234567890abc\"");
sb.append(" ]"); sb.append("}");

HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("IMAPS-Authorization", "Basic " + b64_authval);
httpPost.setHeader("Content-Type", "application/json; charset=UTF-8");
httpPost.setEntity(new StringEntity(sb.toString(),"UTF-8"));

im_response = httpclient.build().execute(httpPost);
上記の例では、Apache HttpClientのOSSを使用しています。