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
hujora
Posts: 4
Registered: ‎11-16-2010
My Device: 8900 Curve

Registration problem with push eval server

Hi,

 

I'm trying to register my device with the push eval server.

My application (widget) send the serviceid, osversion and model of my blackberry device thanks to this (simplified) code :

 

 

var osversion = blackberry.system.softwareVersion;
var model = blackberry.system.model;

params = "/mss/PD_subReg?serviceid=" + serviceid + "&osversion=" + osversion + "&model=" + model;

myXHR = new XMLHttpRequest();
myXHR.open("POST", "https://pushapi.eval.blackberry.com" + params, true);
...

 

 

 

I get in response this text : "Error The content you have requested is not available PD_subReg command is not currently in service!".

 

Is service down ? Am I missing a step ? Is this step necessary (i'm using BIS) ?

 

Help me please :smileyhappy:

 

Regards

Please use plain text.
Developer
massimo_olive
Posts: 235
Registered: ‎11-08-2010
My Device: Not Specified

Re: Registration problem with push eval server

Registration to push eval server must be over http not https

Please use plain text.
New Contributor
hujora
Posts: 4
Registered: ‎11-16-2010
My Device: 8900 Curve

Re: Registration problem with push eval server

Thanks for your reply massimo_olive.

However it does not seem to work. When I use http my xhr returns status 500 with the description "Error requesting resource".

 

https://blackberry.com, http://blackberry.com and their subdomains are allowed in my widget permissions.

In the blackberry navigator i can access blackberry.com but not http://pushapi.eval.blackberry.com/mss/PD_subReg?...

 

Any idea ?

Please use plain text.
New Contributor
hujora
Posts: 4
Registered: ‎11-16-2010
My Device: 8900 Curve

Re: Registration problem with push eval server

Hi,

 

I tried to add ";deviceside=false;ConnectionType=mds-p****" to the end of my url.

It did not work : i got an 500 error .

 

Here is my code :

 

var myXHR;
var encryptedParam;

var BBP_SERVER = "http://pushapi.eval.blackberry.com";
var BBS_TRANSPORT = ";deviceside=false;ConnectionType=mds-p****";

var serviceid = "xxx-xxxxxxxxxxxxxx";
var osversion = blackberry.system.softwareVersion;
var model = blackberry.system.model;

function init() {
	createMenu();
}

function createMenu() {
	var itemRegister = new blackberry.ui.menu.MenuItem(false, 1,
			"Register", register);
	blackberry.ui.menu.addMenuItem(itemRegister);
	
	var itemSubscribe = new blackberry.ui.menu.MenuItem(false, 1,
			"Subscribe", subscribe);
	blackberry.ui.menu.addMenuItem(itemSubscribe);
}

function register() {
	params = "/mss/PD_subReg?serviceid=" + serviceid + "&osversion="
			+ osversion + "&model=" + model;
	try {
		myXHR = new XMLHttpRequest();
		alert("Requete sur : " + BBP_SERVER + params + BBS_TRANSPORT);
		myXHR.open("POST", BBP_SERVER + params + BBS_TRANSPORT, true);
	} catch (err) {
		alert(err);
	}
	myXHR.onreadystatechange = registerHandler;
	myXHR.send();
}

function registerHandler() {
	if (myXHR.readyState == 4) {
		if (myXHR.status == 200) {
			alert("1 myXHR.status == 200");
			encryptedParam = myXHR.responseText;
			validate();
		} else {
			var message = myXHR.getResponseHeader("911");
			if (message.length == null) {
 				alert("3 Error!Status: " + myXHR.status + "Description: " + myXHR.statusText);
			} else {
				alert("4");
				alert(message);
			}
		}
	}
	else {
		alert("3 Error!Status: " + myXHR.status + "Description: "
				+ myXHR.statusText);
	}
}

function validate() {
	params = "/mss/PD_subReg?osversion=" + osversion + "&model=" + model + "&" + encryptedParam;
	try {
		document.getElementById('result').innerHTML = params;
		alert("Requete sur http://pushapi.eval.blackberry.com/mss/PD_subReg?" + params + BBS_TRANSPORT);
		myXHR = new XMLHttpRequest();
		myXHR.open("POST", BBP_SERVER + params + BBS_TRANSPORT
, true); } catch (err) { alert(err); } myXHR.onreadystatechange = getResponse; myXHR.send(); } function getResponse() { if (myXHR.readyState == 4) { if (myXHR.status == 200) { alert("Inscription push reussie"); //document.getElementById('result').innerHTML = myXHR.responseText; } else { var message = myXHR.getResponseHeader("911"); if ((message.length == null) || (message.length <= 0)) { alert("6 Error!Status: " + myXHR.status + "Description: " + myXHR.statusText); } else { document.getElementById('result').innerHTML = message; } } } } var port = XXXXX; //alert("PIN: " + blackberry.identity.PIN); function subscribe() { alert('subscribe'); blackberry.push.openPushListener(handleReturnData, port); } function handleReturnData(data) { if (data != null) { var text = blackberry.utils.blobToString(data.payload); alert(text); } } function unsubscribe() { blackberry.push.closePushListener(port); }

 

 

 

 Help me please :smileyhappy:

 

Regards

 

 

Please use plain text.
Contributor
binnyb
Posts: 19
Registered: ‎11-02-2010
My Device: Not Specified

Re: Registration problem with push eval server

[ Edited ]

I am also getting this same error, 500 internal server error. another error message says "Select proper transport Descriptor for:http://pushapi.eval.blackberry.com/mss/PD_subReg?serviceid=MY_APP_ID&osversion=MY_OS_VERSION&model=M..."

 

I have edited the rim:connection in the config.xml file as I was told i needed to use BIS-B for registration:

but i still run into the same problem.

 

<rim:connection timeout="60000">
    <id>BIS-B</id>
    <id>MDS</id>
    <id>TCP_WIFI</id>
    <id>TCP_CELLULAR</id>
    <id>WAP2</id>
    <id>WAP</id>
  </rim:connection>

 

<rim:connection timeout="60000">    <id>BIS-B</id>    <id>MDS</id>    <id>TCP_WIFI</id>    <id>TCP_CELLULAR</id>    <id>WAP2</id>    <id>WAP</id>  </rim:connection>

 

if someone could give us a hand here it would be great!

Please use plain text.
New Contributor
hujora
Posts: 4
Registered: ‎11-16-2010
My Device: 8900 Curve

Re: Registration problem with push eval server

I found (thanks to the dev support) the solution.

In Options -> Advanced Options -> Service Book you should have :

- BlackBerry Internet Browsing Service [BrowserConfig]
- BlackBerry Internet Browsing Service 2 [BrowserConfig]

If you can not locate these service books you must buy a BlackBerry Data Plan in order to activate BIS.

 

Here's my final code :

 

Server :

 

 

<?php
/*
 * Dependencies : curl & libxml
 */

if ($_POST) {
    // APP ID provided by RIM
    $appid = '****-****************';
    // Password provided by RIM
    $password = '**********';
    
    //Deliver before timestamp
    $deliverbefore = gmdate('Y-m-d\TH:i:s\Z', strtotime('+5 minutes'));
    
    //An array of address must be in PIN format or "push_all"
    $addresstosendto[] = 'push_all';
    
    $addresses = '';
    foreach ($addresstosendto as $value) {
        $addresses .= '<address address-value="' . $value . '"/>';
    }
    
    // create a new cURL resource
    $err = false;
    $ch = curl_init();
    $messageid = microtime(true);

    $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" .
    stripslashes($_POST['message']) . "\r\n" .
    '--mPsbVQo0a68eIL3OAxnm--' . "\n\r";

	// settings
    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";
    }
} 
?>

 

Client :

 

 

var myXHR;
	var encryptedParam;

	var BBP_SERVER = "http://pushapi.eval.blackberry.com";
	var BBS_TRANSPORT = ""; //;deviceside=false;ConnectionType=mds-**blic";

	var port = *****;
	var serviceid = "****-****************";
	var osversion = blackberry.system.softwareVersion;
	var model = blackberry.system.model;

	var $ = function(s) { return document.getElementById(s); }

	function init() {
		createMenu();
	}

	function createMenu() {
		var itemRegister = new blackberry.ui.menu.MenuItem(false, 1,
				"Register", register);
		blackberry.ui.menu.addMenuItem(itemRegister);
		
		var itemSubscribe = new blackberry.ui.menu.MenuItem(false, 1,
				"Subscribe", subscribe);
		blackberry.ui.menu.addMenuItem(itemSubscribe);
	}

	function register() {
		params = "/mss/PD_subReg?serviceid=" + serviceid + "&osversion="
				+ osversion + "&model=" + model;
		try {
			myXHR = new XMLHttpRequest();
			alert("Requete sur : " + BBP_SERVER + params + BBS_TRANSPORT);
			myXHR.open("POST", BBP_SERVER + params + BBS_TRANSPORT, true);
		} catch (err) {
			alert(err);
		}
		myXHR.onreadystatechange = registerHandler;
		myXHR.send();
	}

	function registerHandler() {
		if (myXHR.readyState == 4) {
			if (myXHR.status == 200) {
				alert("1 myXHR.status == 200");
				encryptedParam = myXHR.responseText;
				validate();
			} else {
				var message = myXHR.getResponseHeader("911");
				if (message.length == null) {
					alert("3 Error!Status: " + myXHR.status + "Description: "
							+ myXHR.statusText);
				} else {
					alert("4");
					alert(message);
				}
			}
		}
		else {
			alert("3 Error!Status: " + myXHR.status + "Description: "
					+ myXHR.statusText);
		}
	}
	
	function validate() {
		params = "/mss/PD_subReg?osversion=" + osversion + "&model=" + model
				+ "&" + encryptedParam;
		try {
			$('result').innerHTML = params;
			alert("Requete sur http://pushapi.eval.blackberry.com/mss/PD_subReg?"
					+ params + BBS_TRANSPORT);
			myXHR = new XMLHttpRequest();
			myXHR.open("POST", BBP_SERVER + params + BBS_TRANSPORT, true);

		} catch (err) {
			alert(err);
		}
		myXHR.onreadystatechange = getResponse;
		myXHR.send();
	}

	function getResponse() {
		if (myXHR.readyState == 4) {
			if (myXHR.status == 200) {
				alert("Inscription push reussie");
				$('result2').innerHTML = myXHR.responseText;
			} else {
				var message = myXHR.getResponseHeader("911");
				if ((message.length == null) || (message.length <= 0)) {
					alert("6 Error!Status: " + myXHR.status + "Description: "
							+ myXHR.statusText);
				} else {
					//$('result').innerHTML = message;
				}
			}
		}
	}

	
	/*
	 * Subscribe
	 */

	function subscribe() {
		alert('subscribe');
		blackberry.push.openPushListener(handleReturnData, port);
	}

	function handleReturnData(data) {
		if (data != null) {
			var text = blackberry.utils.blobToString(data.payload);
			alert(text);
		}
	}

	function unsubscribe(){
		blackberry.push.closePushListener(port);
	}

 

 

I hope this will help someone :smileyhappy:

 

Please use plain text.
Developer
csibbdev
Posts: 67
Registered: ‎09-23-2010
My Device: Curve
My Carrier: T-Mobile

Re: Registration problem with push eval server

This is awesome - thank you so much for posting this.

 

I have encountered an error on registration - Cannot convert 'null' to an object.

 

It seems to be in the following code where it pops up.

 

new XMLHttpRequest();"POST", BBP_SERVER + params + BBS_TRANSPORT, true);

any idea where I may be going astray?

Thanks

Please use plain text.
Developer
csibbdev
Posts: 67
Registered: ‎09-23-2010
My Device: Curve
My Carrier: T-Mobile

Re: Registration problem with push eval server

N evermind I found it

Please use plain text.