06-15-2010 05:59 AM
Hi guys.
I need to send push notifications to BB users of my BB App. I have registered for the service and had also received the email for my successfull registration.
My RIM mail says that the URL to push msg is:
https://pushapi.eval.blackberry.com
Is the url correct to push the data because the URL that i find in many sample examples is:
https://pushapi.eval.blackberry.com/push?DESTINATION=APP-ID&PORT=PORT_NO&REQUESTURI=localhost
I am confused about the DESTINATION field.
I am also having another URL:
https://pushapi.eval.blackberry.com/mss/PD_pushReq uest
Now what this URL is for??
All these URL's confuses me. Can some one please help me to make a pust request to the BB server. It will be really helpfull if some one can assist me with the java code for it.
I had gone through the code of sample-app and debug-portal.
All i understand is that i just need to make an http Request to the above metioned URL. If i need to send the username and password for the authentication then how should i send it in the request. Any specific format. I am coding in JAVA server side.. Blackberry is very new to me.
Any help will be appreciated. Please reply to the post soon, have some tight deadlines.
Regards
Vibhu
06-15-2010 08:47 AM - edited 06-15-2010 08:47 AM
pushapi.eval.blackberry.com is the push server to use for the push evaluation service
https://pushapi.eval.blackberry.com/mss/PD_pushReq is the URL to use to post a push request.
You have to authenticate your request with basic authentication, using your appID as username and the provided service password as the ... password ![]()
The request itself must follow the PAP specs available at www.openmobilealliance.com http://www.openmobilealliance.org/technical/releas
06-15-2010 04:26 PM
Thx for the reply ranguard..
Need to know how to authenticate the request for pushing data to the BB server..
https://pushapi.eval.blackberry.com/mss/PD_pushReq is the push url.
Can you help me to find a simple java example to send push message which incllude authentication too. I found few examples but was not able to figure out how the authentication is sent..
I have also installed the pushsdk api. Please help me to fugure out the necessary steps for sending a push request to the BB server..
Thanks
Your help is really appreciated..
06-16-2010 03:56 AM - edited 06-16-2010 04:00 AM
For authentication you must use "basic authentication", which is a standard http mechanismn:
This is done by setting the HTTP request header
"Authorization"
to
"Basic <bas64 encoded string of user:password>"
The user must be your app ID - lets say 55-65F234A63E4F - the password is the service password named Pwd in the server section of your credentials mail - lets say "s3cr3tp@55".
Dependent on the used java http client library you can set some BasicAutenticator-Object to your HttpConnection or you can set the header directly:
pushConnection.setRequestProperty("Authorization", "Basic NTUtNjVGMjM0QTYzRTRGOnMzY3IzdHBANTU=");
Where NTUtNjVGMjM0QTYzRTRGOnMzY3IzdHBANTU= is the base64 encoded string 55-65F234A63E4F:s3cr3tp@55
Try http://www.motobit.com/util/base64-decoder-encoder
Hope my writing is understandable ![]()
06-16-2010 06:25 AM - edited 06-17-2010 02:42 AM
Hi ranguard,
You writing can be understood clearly. ![]()
I had implemented it with the authorization. While i do a pap push it gives me that
mds returned status code 200:
Below is my pap push code:
private void papPush(String data)
{
String pushId="pushID:"+random.nextInt();
setupNotifyThread();
readPapTemplate();
String errorCode = null;
try {
String mdsHost = "pushapi.eval.blackberry.com/mss/PD_pushReq";
URL mdsUrl = new URL("https://"+mdsHost+ "/pap");
System.out.println(" sending PAP request to " + mdsUrl.toString() + "; pushId = " + pushId);
HttpURLConnection mdsConn = (HttpURLConnection)mdsUrl.openConnection();
String boundary = "";
boundary = "asdlfkjiurwghasf";
mdsConn.setRequestProperty("Content-Type", "multipart/related; type=\"application/xml\"; boundary=" + boundary);
mdsConn.setRequestProperty("X-Wap-Application-Id", "/");
mdsConn.setRequestProperty("X-Rim-Push-Dest-Port","20484");
String base64 = "***************************************";
mdsConn.setRequestProperty("Authorization", base64);
mdsConn.setRequestMethod("POST");
mdsConn.setAllowUserInteraction(false);
mdsConn.setDoInput(true);
mdsConn.setDoOutput(true);
String output = requestTemplate.replaceAll("\\$\\(pushid\\)", pushId);
output = output.replaceAll("\\$\\(boundary\\)", boundary);
output = output.replaceAll("\\$\\(notifyURL\\)", "" + notifyURL);
output = output.replaceAll("\\$\\(pin\\)", "" + _pinField.getText());
String deliveryMethod = "confirmed";
output = output.replaceAll("\\$\\(deliveryMethod\\)", deliveryMethod);
output = output.replaceAll("\\$\\(headers\\)", "Content-Type: text/plain");
output = output.replaceAll("\\$\\(content\\)", data);
output = output.replaceAll("\r\n", "EOL");
output = output.replaceAll("\n", "EOL");
output = output.replaceAll("EOL", "\r\n");
System.out.println(output);
OutputStream outs = mdsConn.getOutputStream();
copyStreams(new ByteArrayInputStream(output.getBytes()), outs);
mdsConn.connect();
ByteArrayOutputStream response = new ByteArrayOutputStream();
copyStreams(mdsConn.getInputStream(), response);
int httpCode = mdsConn.getResponseCode();
if (httpCode != HttpURLConnection.HTTP_ACCEPTED) {
throw new Exception("MDS returned HTTP status: " + httpCode);
}
} catch (Exception exception) {
if (errorCode == null)
{
errorCode = exception.getClass().getName();
}
System.out.println(" encountered error on submission: " + exception.toString());
}
}
And when i do a rim push to the provided url i get complete web page in response.
The page shows some error saying:
Sending to https://pushapi.eval.blackberry.com/mss/PD_pushReq
Response: Content Length: 1237
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Pushdata Service</title>
<body bgcolor="white" leftmargin="0" marginheight="0" marginwidth="0" topmargin="0">
<form enctype="application/x-www-form-urlencoded" method="get">
<!-- Header -->
<!-- static error header library -->
<br clear="none"/>
<!-- Errorcode -->
<!-- dynamic @[errorcode] token -->
<font color="#777777" size="1" style="verdana">Error </font>
<br clear="none"/>
<br clear="none"/>
<!-- Errorbody -->
<!-- dynamic @[errorbody] token -->
<font color="#777777" size="1" style="verdana">The content you have requested is not available</font>
<br clear="none"/>
<!-- Error message -->
<!-- dynamic @[errormsg] token -->
<br clear="none"/>
<font color="#777777" size="1" style="verdana">PD_pushReq command is not currently in service!</font>
<br clear="none"/>
<br clear="none"/>
<!-- Footer -->
<!-- static error footer library -->
<br clear="none"/>
</form>
</body>
</html>
Can you please put some light on these responses..
Regards
06-16-2010 08:48 AM - edited 06-16-2010 08:51 AM
I have a similar problem (on the production system) when trying to register a client. Some error 500 stating "PD_subReg ist currently not in service".
I have seen a few "PD_pushReq has been taken out of service" messages as well within the last week.
Strange ...
06-17-2010 02:24 AM
Ranguard how should i move further?
The responce code of 200 from pap push means that the message is sent successfully?
I have seen a few "PD_pushReq has been taken out of service" messages as well within the last week.
What does this means. Is there a problem from blackberry side??
06-17-2010 02:55 AM - edited 06-17-2010 03:03 AM
Ranguard how should i move further?
You need some clients to be registered for your service.
The responce code of 200 from pap push means that the message is sent successfully?
No ...200 just tells you the service could be reached and your request was submitted successfully.
In addition you get back a XML response with further information about the state of your request.
The following is an example for a response reflecting a successful push (result code 1001 is the key to a successful push):
<?xml version="1.0"?> <!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 2.1//EN" "http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd"><pap><push-response push-id="id57342836" sender-add ress="http://pushapi.eval.blackberry.com/mss/PD_pushRequ
est" sender-name="RIM Push-Data Service" reply-time="2010-06-17T06:38:42Z"><response-result code="1001" desc="The request has been accepted for processing."></response-result></push-response></p ap>
You can get a bunch of different error messages back. Some will be of type response-result like the success message but with some different result code and message text - or if your message is malformed somehow you will get a badmessage-response:
<?xml version="1.0"?> <!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 2.1//EN" "http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd"><pap><badmessage-response code="2000" desc="deliver-before-timestamp has already expired" bad-message-fragment="deliver-before-timestamp has already expired"/></pap>
What does this means. Is there a problem from blackberry side??
That's what I'm thinking about this whole stuff.
But RIM tries some Jedi approach by doing some weird gesture and repeating to say "There is no problem" ![]()
06-17-2010 07:34 AM
You mentioned that :
In addition you get back a XML response with further information about the state of your request.
How will i get the XML. The httpconnection that am using to make the push results me in the response code:200
Where will i get the xml from
Please suggest
Thanks in advance..
06-17-2010 08:46 AM
Oh ... forgot to mention ... ![]()
It 's the response body!
Simply get some DataInputStream or something from yout HttpConnection and parse the content.