需要帮助才能让 blackberry webworks 推送演示与 Urban Airship 配合使用

发布于 2024-11-06 13:03:38 字数 4005 浏览 0 评论 0原文

我已经从 此处 在模拟器中工作。

当我在黑莓设备(BlackBerry Bold 9000)上尝试使用 UrbanAirship 测试推送消息时,我无法收到任何推送通知。

到目前为止我所做的事情有: * 将推送端口从 100 更改为 29580 * 将应用程序 ID 作为属性添加到 config.xml 中的小部件元素中 * 申请表在上传到手机之前已经过签名。 * 我假设代码中没有错误,因为启动/停止订阅警报消息都出现在应用程序启动/按钮单击上 * 当 UrbanAirship 发送测试消息时,没有网络活动的迹象。

我的 config.xml 文件如下所示:

<?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="[email protected]">
    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>

action.js 文件如下所示:

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

最后,我的 index.html 文件如下所示:

<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>

有人知道我的代码/配置可能有什么问题吗?

干杯, 斯蒂芬

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="[email protected]">
    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:subscribe();">
        <button id="btnUnsubscribe" onclick="unsubscribe();">Unsubscribe</button>
    </body>
</html>

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

Cheers,
Stephen

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文