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
New Contributor
victorhugo
Posts: 8
Registered: ‎07-23-2013
My Device: Dev Alpha B
My Carrier: BB

Re: Problem with SEND Push Notification!

Sorry! 

But processing returns 

 

Response CODE: 1001
Response DESC: The request has been accepted for processing.

 

 

 

And the android.cfg

 

 

<?xml version="1.0" encoding="utf-8"?>
<android>
   <push>
      <appid>MY_APPID</appid>
      <ppgurl>http://cpMY_APPID.pushapi.eval.blackberry.com</ppgurl>
	  <tokenprefix></tokenprefix>
   </push>
</android>

 

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Problem with SEND Push Notification!

Stray comment about spaces: it's not necessary to have a blank line *after* the payload, only before it. If you include another line afterwards you'll just have to strip it in the app (if you don't want it there) and are wasting a whole two bytes (CR + LF) out of your 8K quota. ;-)

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
sho3ebovich
Posts: 117
Registered: ‎12-22-2011
My Device: ---
My Carrier: ---

Re: Problem with SEND Push Notification!

Dears , 

 

I'm trying to use the same code posted previously ,and adding new lines but i still get 

Our PUSH-ID: 1381237403.2695
An XML parser error has occured

Invalid document end
Response

 

the code i used 

public function sendNotificationBlackBerry($registatoin_tokens, $message) {
$appid = '2550-53737re03i2O7651e5c79i252597aa6s4B6'; // 4038-8si785997a3eir572168c5f821291rl8a84
//$password = 'Ja50N4Hu1d';
$password = 'dsvoolM5';
$boundary = "JcX58MAjkOhziP7";
$boundary = "mPsbVQo0a68eIL3OAxnm";
$appport = "33872";
$deliverbefore = gmdate('Y-m-d\TH:i:s\Z', strtotime('+2 minutes'));
//An array of address must be in PIN format or "push_all"
$addresses = '';
foreach ($registatoin_tokens as $value) {
$addresses .= '<address address-value=' . $value . '/>';
}
// create a new cURL resource
$ch = curl_init();
$messageid = microtime(true);
$data = '--' . $boundary . "\r\n" .
'<?xml version="1.0" charset="UTF-8"?>
<!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 . '" source-reference="' . $appid . '" deliver-before-timestamp="' . $deliverbefore . '">'
. $addresses .
'<quality-of-service delivery-method="confirmed"/>
</push-message>
</pap>' . "\r\n" .
'--' . $boundary . "\r\n" .
'Content-Type: text/plain' . "\r\n\n" .
'Push-Message-ID: ' . $messageid . "\r\n\r\n" .
stripslashes($message) . "\r\n\n" .
'--' . $boundary . '--' . "\n\r";
// set URL and other appropriate options
// curl_setopt($ch, CURLOPT_URL, "https://pushapi.eval.blackberry.com/mss/PD_pushRequest"); //Erro code 2000 The request is invalid.
curl_setopt($ch, CURLOPT_URL, "https://cp2550.pushapi.eval.blackberry.com/mss/PD_pushRequest"); // Error CODE: 2000
// curl_setopt($ch, CURLOPT_URL, "https://pushapi.eval.blackberry.com"); // Invalid document end
// curl_setopt($ch, CURLOPT_URL, "https://cp2550.pushapi.eval.blackberry.com"); //Invalid document end
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_USERAGENT, "SAA push application");
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_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: multipart/related; boundary=" . $boundary . "; type=application/xml", "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2", "Connection: keep-alive"));
// grab URL and pass it to the browser
$xmldata = curl_exec($ch);
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";
echo '<pre>' . $xmldata . '</pre>' . "\n";
var_dump($xmldata);
}
// -----------------------------
 
return $xmldata;
}

 

please help me 

Please use plain text.
BlackBerry Development Advisor (Retired)
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: Problem with SEND Push Notification!

Hi there 

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.