Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

BlackBerry Push Development

Reply
Highlighted
Visitor
Posts: 1
Registered: ‎10-17-2013
My Device: 8520
My Carrier: 4wet436436

Push notifications blackberry OS7< are not reaching devices php server

[ Edited ]

I am developing an app in BB OS 5 and 7. Push notifications reached in past but eval key caduced and we created a new one with new code signing files.

I changes the code signing files in eclipse and now I can upload programs with new ones.

I received today data for push notifications. AppId, Pwd, CPID (dont know what this is for), Appid for client and push port.

This is my code in php for sending push notifications:

 

<?php
function bbPush($pushToken , $message){
// APP ID provided by RIM
$appid = '****-*************************************';
// Password provided by RIM
$password = '********';
//Deliver before timestamp
$deliverbefore = gmdate('Y-m-d\TH:i:s\Z', strtotime('+125 minutes'));
//An array of address must be in PIN format or "push_all"
$addresstosendto[] = $pushToken;
$addresses = '';
foreach ($addresstosendto as $value) {
$addresses .= '<address address-value="' . $value . '"/>';
}
// create a new cURL resource
$err = false;
$ch = curl_init();
$messageid = microtime(true);
//$message = 'New Event in category:' . $nameEvent . " en " . $kind;
$data = '--mPsbVQo0a68eIL3OAxnm'. "\r\n" .
'Content-Type: application/xml; charset=UTF-8' . "\r\n\r\n" .
'<?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-message push-id="' . $messageid . '" deliver-before-timestamp="' . $deliverbefore . '" source-reference="' . $appid . '">'
. $addresses .
'<quality-of-service delivery-method="unconfirmed"/>
</push-message>
</pap>' . "\r\n" .
'--mPsbVQo0a68eIL3OAxnm' . "\r\n" .
'Content-Type: text/plain' . "\r\n" .
'Push-Message-ID: ' . $messageid . "\r\n\r\n" .
$message . "\r\n" .
'--mPsbVQo0a68eIL3OAxnm--' . "\n\r";
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "https://pushapi.eval.blackberry.com/mss/PD_pushRequest");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_USERAGENT, "Hallgren Networks BB Push Server/1.0");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $appid . ':' . $password);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: multipart/related; boundary=mPsbVQo0a68eIL3OAxnm; type=application/xml", "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2", "Connection: keep-alive"));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// grab URL and pass it to the browser
$xmldata = curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
//Start parsing response into XML data that we can read and output
$p = xml_parser_create();
xml_parse_into_struct($p, $xmldata, $vals);
$errorcode = xml_get_error_code($p);
if ($errorcode > 0) {
$err = true;
}
xml_parser_free($p);
echo 'Our PUSH-ID: ' . $messageid . "<br \>\n";
if (!$err && $vals[1]['tag'] == 'PUSH-RESPONSE') {
echo 'PUSH-ID: ' . $vals[1]['attributes']['PUSH-ID'] . "<br \>\n";
echo 'REPLY-TIME: ' . $vals[1]['attributes']['REPLY-TIME'] . "<br \>\n";
echo 'Response CODE: ' . $vals[2]['attributes']['CODE'] . "<br \>\n";
echo 'Response DESC: ' . $vals[2]['attributes']['DESC'] . "<br \> \n";
} elseif ($err) {
echo '<p>An XML parser error has occured</p>' . "\n";
echo '<pre>' . xml_error_string($errorcode) ."</pre>\n";
echo '<p>Response</p>' . "\n";
echo '<pre>' . $xmldata . '</pre>' . "\n";
} else {
echo '<p>An error has occured</p>' . "\n";
echo 'Error CODE: ' . $vals[1]['attributes']['CODE'] . "<br \>\n";
echo 'Error DESC: ' . $vals[1]['attributes']['DESC'] . "<br \>\n";
}
}
?>

 

 

I created another file for executing this function passing a pushToken value:

 

<?php
include 'bb_push.php';
echo "start";

bbPush('********', 'hey friends');

echo "end";
?>

 

 

I set in the first php code, the App ID and password writen in the push initiator part(server application).

And in BB code, I use This:

 

private static final String PUSH_PORT = ""+"****"; //push port
private static final String BPAS_URL = "http://pushapi.eval.blackberry.com";
private static final String APP_ID = ""+ "****-**************************************"; // add application id
private static String URL = "http://:"+ "******"; // add your push port.

 

 

Same port in both lines. The app id is from he client application part of the mail received from RIM.

I know the push notification were recived in past, so I guess the BB code is ok and the server side also does. I think my problem is from the app id or something.

If I execute the test.php file, what I get on browser is:

 

startOur PUSH-ID: **********.****
PUSH-ID: **********.****
REPLY-TIME: 2013-10-17T08:02:45Z
Response CODE: 1001
Response DESC: The request has been accepted for processing.
end

 

 

So I guess it is working (doesn't it?) But nothing is received on BB. I switch it off and on again but nothing.


In the mail I received from RIM, it says:
Please update your base URL to reflect the CPID you are assigned.

This is the base URL http:// cp(your App ID ).pushapi.eval.blackberry.com, where do I have to use this?