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

New Contributor
Posts: 4
Registered: ‎04-08-2014
My Device: z10
My Carrier: Orange
Accepted Solution

PHP push notification - type of registration

I need to send notification messages to bb10 devices using PHP script from my server. I've used the BlackBerry Push Service Evaluation form to register, choosing BlackBerry Internet Service as Transport for Pushes and Blackberry Push Essentials as Push Service type.

I have checked posts, including this one that seems to have been solved (http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Problem-with-SEND-Push-Notificati... and making all kind of changes to data to be sent and headers, but no luck: push server does not respond (curl_exec is false), and trying to parse xml ends with error
An XML parser error has occured
Invalid document end

The data sent now has the form:
$data = '--' . $boundary .
'<?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">
<push-message push-id="' . $messageid . '" source-reference="' . $appid . '" deliver-before-timestamp="' . $deliverbefore . '"><address address-value="push_all"></address>
<quality-of-service delivery-method="unconfirmed"></quality-of-service>
</pap>' .
'--' . $boundary . "\r\n" .
'Content-Type: text/plain' . "\r\n" .
'Push-Message-ID: ' . $messageid . "\r\n\r\n" .
stripslashes($message) . "\r\n" .
'--' . $boundary . '--';

And curl transfer options are set like:
curl_setopt($ch, CURLOPT_URL, "https://cpXXXX.pushapi.eval.blackberry.com/mss/PD_pushRequest"); (replaced xxxx with value from registration email)
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_USERAGENT, "SAA push application");
curl_setopt($ch, CURLOPT_USERPWD, $appid . ':' . $password); (replaced appid and password with values from registration email)
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: multipart/related; boundary=" . $boundary . "; type=application/xml"));

2. Tried using javascript to POST XMLHttpRequest in on a page on the same server. The result was:
XMLHttpRequest cannot load https://cpxxxx.pushapi.eval.blackberry.com/mss/PD_pushRequest. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://my_server_address' is therefore not allowed access.

3. I used the same XMLHttpRequest code in a webworks app launched from z10 device(the code can be found here - https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/pushCaptureBasics/pushInitiator) and
here is the result:
<response-resultcode="1001"desc="The request has been accepted for processing."></response-result>
...and the Capture application seems to catch the notification, as it launches on new push (doesn't show the message, but that's another thing ).

The only thing that comes now to my mind is that the push server does not accept push messages from my server. But how to solve this?
Any kind of guidance is highly appreciated.


New Contributor
Posts: 4
Registered: ‎04-08-2014
My Device: z10
My Carrier: Orange

Re: PHP push notification - type of registration

Well, happy to have found an solution to this: after getting the BlackBerry Push Service Production Credentials have used them and it actually works with this code here  http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Cannot-send-PHP-Push-message-usin...