やっとプッシュリクエストできました。BlackBerry サーバーにプッシュする必要があります。ここで入手できる BB SDK を使用しました。使用する URL は次のようになります。
https://cpXXX.pushapi.eval.blackberry.com/mss/PD_pushRequest
サンプルコード:
IdGenerator idGenerator = new IdGeneratorImpl();
List<String> addresses = new ArrayList<String>();
JSONObject message = new JSONObject();
//populate message with key-value pairs
String data = message.toString();
//populate addresses with device PINs
PushMessageControl pushMessageControl = new PushMessageControl(PPGType.PUBLIC_PUSH, idGenerator, "[ YOUR BlackBerryAppId]", addresses);
Content content = new TextContent(data, "UTF-8");
PapService papService = new PapServiceImpl();
PushSDKProperties properties = new PushSDKPropertiesImpl();
properties.setPublicPpgAddress("[YOUR BLACKBERRY PPG ADDRESS]");
properties.setParserSpecialCharacters(BLACKBERRY_PARSER_SPECIAL_CHARACTERS);
properties.setHttpIsPersistent(false);
properties.setHttpConnectionTimeout(BLACKBERRY_CONNECTION_TIMEOUT);
properties.setDtdDeclarationPublic(BLACKBERRY_DTD_DECLARATION_PUBLIC);
properties.setHttpReadTimeout(BLACKBERRY_READ_TIMEOUT);
HttpClientImpl client = new HttpClientImpl();
client.setPushSDKProperties(properties);
papService.setHttpClient(client);
papService.setPushSDKProperties(properties);
PushResponse response = papService.push("[ YOUR BlackBerryAppId]", "[ YOUR BlackBerryPassword]", "[ YOUR BlackBerryAppId]", pushMessageControl, content);
どこ
private static final int BLACKBERRY_READ_TIMEOUT = 120000;
private static final int BLACKBERRY_CONNECTION_TIMEOUT = 60000;
private static final char[] BLACKBERRY_PARSER_SPECIAL_CHARACTERS = new char[] {'&', '"', ':', '<'};
private static final String BLACKBERRY_DTD_DECLARATION_PUBLIC = "<!DOCTYPE pap PUBLIC \"-//WAPFORUM//DTD PAP 2.1//EN\" \"http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd\">";