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

Web and WebWorks Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Visitor
Posts: 1
Registered: ‎05-09-2011
My Device: 9550
My Carrier: optus

Help needed for getting the push demo to work with Urban Airship.

Hello everyone.

 

I have gotten the Push Demo from here to work in the simulators.

 

When I tried it on a blackberry device (BlackBerry Bold 9000) with the UrbanAirship Test Push messages, I was not able to receive any push notifications.

 

Things that I have done so far are:

  • Changed the push port from 100 to 29580
  • Added the application id as an attribute to the widget element in config.xml
  • The application has been signed before uploaded to the phone.
  • I'm assuming no errors in the code because both start/stop subscribe alert messages appear on app start/button click
  • There is no indication of network activity when a test message has been sent by UrbanAirship.

My config.xml file looks like this:

 

<?xml version="1.0" encoding="utf-8"?>
<widget xmlns:rim="http://www.blackberry.com/ns/widgets" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" id="{app_id}">
	<name>Push Example</name>
	<description>Samples of code</description>
	<author href="http://www.rim.com/" rim:copyright="no copyright" email="webapi@rim.com">
	Research in Motion - Web API Team
	</author><content src="index.htm" />
	<feature id="blackberry.system" required="true" version="1.0.0.0" />
	<feature id="blackberry.app" required="true" version="1.0.0.0" />
	<feature id="blackberry.invoke.JavaArguments" required="true" version="1.0.0.0" />
	<feature id="blackberry.invoke.CalendarArguments" required="true" version="1.0.0.0" />
	<feature id="blackberry.invoke" required="true" version="1.0.0.0" />
	<feature id="blackberry.push" version="1.0.0"/>
	<feature id="blackberry.identity" version="1.0.0"/>
	<feature id="blackberry.utils" required="true" version="1.0.0.0" />
	<rim:connection timeout="30000">
		<id>MDS</id>
		<id>BIS-B</id>
		<id>TCP_WIFI</id>
		<id>TCP_CELLULAR</id>
		<id>WAP2</id>
		<id>WAP</id>
	</rim:connection>
	<license href="http://www.license.com">This is a sample license</license>
</widget>

 

 

 

The action.js file looks like this:

 

//the port that the Push Listener will listen to on the MDS
//Open the rimpublic.property file, which is located in the MDS\config subdirectory
//of your BlackBerry Email and MDS Services Simulators installation directory.
//Ensure the "push.application.reliable.ports=100" line is NOT commented out.
var port = 29580;

function subscribe() {
    //open the listener to listen if there is pushed data coming through
    blackberry.push.openPushListener(handleReturnData, port);
	try {
		alert("push listening has started. push port = ("+port+") app id = (" + blackberry.app.id + ") pin = ("+blackberry.identity.PIN+")");
	} catch (e) {
		alert (e);
	}
}

//handleReturnData - the function to call for the event of pushed data coming through
//port - the port to listen on
function handleReturnData(data) {
	try {
		if (data != null) {
			var text = blackberry.utils.blobToString(data.payload);
			alert("text recieved from push: " + text);
		} else {
			alert("No data from the push");
		}
	} catch (e) {
		alert (e);
	}
}

function unsubscribe() {
    //stop listening for pushed data, a clean up step
    blackberry.push.closePushListener(port);
    alert("Push listening has stopped");
}

 

 

Finally, my index.html file looks like this:

 

<html>
	<head>
		<title>Push Example</title>
		<script src="Scripts/action.js" type="text/javascript"></script>
		<link href="Styles/styles.css" rel="stylesheet" type="text/css" />
	</head>
	<body onload="javascript&colon;subscribe();">
		<button id="btnUnsubscribe" onclick="unsubscribe();">Unsubscribe</button>
	</body>
</html>

 

 

Would anyone know what could be wrong with my code/configuration?

 

Cheers,

Stephen