Question

Is there any codeigniter library to implement push notification for Blackberry apps (version 5-7). Or can anybody help out with the process of implementing blackberry's push notification service in codeigniter.?

No correct solution

OTHER TIPS

I dont think that is there any library for code igniter - blackberry push notification.

But

Here is the process and code to implement the push notification for blackberry which we are currently using in so many app and web services.

$appid = '311-hh81l706993itR79O4021oom4847e332o472';

// Password provided by RIM
$password = 'SNuwGoR7';

// Application device port
$appport =33489;

//Deliver before timestamp
$deliverbefore = gmdate('Y-m-d\TH:i:s\Z', strtotime('+10 minutes'));

//here $deviceToken is the device tiken of device to which you want to send message //Example: b568t452
$addresses = '<address address-value="' .$deviceToken. '"/>';


//$data is an array of data which you want to send via push message
$messages=json_encode($data);

// create a new cURL resource
$err = false;
$ch = curl_init();
$messageid = microtime(true);
$data = '--asdwewe. "\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" .        '--asdwewe' . "\r\n" .        'Content-Type: text/plain' . "\r\n" .                    'Push-Message-ID: ' . $messageid . "\r\n\r\n" .$messages. "\r\n" .        '--asdwewe--' . "\r\n";

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "https://cp311.pushapi.na.blackberry.com/mss/PD_pushRequest");

curl_setopt($ch, CURLOPT_PORT , 443);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_CAINFO, getcwd()."\cacert.pem");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_USERAGENT, "My 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);

$__extra_Headers = array(
"Content-Type: multipart/related; boundary=asdwewe; type=application/xml",
"Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2",
"Connection: keep-alive",
"X-Rim-Push-Dest-Port: ".$appport,
"X-RIM-PUSH-ID: ".$messageid,
"X-RIM-Push-Reliability-Mode: APPLICATION"
);

curl_setopt($ch, CURLOPT_HTTPHEADER, $__extra_Headers);

// grab URL and pass it to the browser
$xmldata = curl_exec($ch);
if($xmldata === false){
echo 'Error pada CURL : ' . curl_error($ch)."\n";
}else{
echo 'Operasi push berhasil'."\n";
}

// 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) {
echo xml_error_string($errorcode)."\n";
$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";
} 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";
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top