Help needed for getting the blackberry webworks push demo to work with Urban Airship
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 开发者_Python百科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:subscribe();">
<button id="btnUnsubscribe" onclick="unsubscribe();">Unsubscribe</button>
</body>
</html>
Would anyone know what could be wrong with my code/configuration?
Cheers, Stephen
精彩评论