I'mm having problems when trying to push notifications for my Z10. The device successfully registers for push notifications and I receive the BlackBerry generated registration ID as described in "Creating Push-Enabled Android Apps".
I am having problems though when trying to send notifications to that server.
For regular Android I was using a GCM server library. I had to modify it so that the message is sent to BlackBerry servers i.e. https://cpXXX.pushapi.eval.blackberry.com where XXX is my CPID (Content Provider ID).
The problem is that I receive a 404 in return and don't know what's causing that... Any ideas? the same message gets sent to a regular Android device successfully...
Alternatively, did anyone succeed in sending push messages to your device and if so, could you share how the request should look like?
Finally, I was able to make a push request. You have to push it to BlackBerry servers. I used BB SDK available here. The URL you have to use should look like this:
https://cpXXX.pushapi.eval.blackberry.com/mss/PD_pushRequest
sample code:
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);
where
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\">";