简体   繁体   English

在Blackberry Webworks中使用Html5通知

[英]Using Html5 Notification in Blackberry Webworks

I am using HTML5 Local Notifications in Blackberry 10 (Higher Version BB z10) using webworks 1.0 我正在使用Webworks 1.0在Blackberry 10(更高版本的BB z10)中使用HTML5本地通知

And it works fine for Me. 它对我来说很好。

The code used look like this. 使用的代码如下所示。

    var n = new Notification("MyMessage", {
            'body' : content.message,
            'tag': content.chatid,
            'target' : "MyMessage",
            'targetAction' : "bb.action.OPEN"

            });

The link of this api reference is here 此api参考的链接在这里

Blackberry Webworks Notification Blackberry Webworks通知

Now there is one more field as "" 现在还有一个字段为“”

payload: Payload to send to the invoked app. 有效负载:要发送到调用的应用程序的有效负载。 Data must be Base64 encoded. 数据必须是Base64编码的。 Value is passed on to the Invocation Framework as data. 值作为数据传递给调用框架。

This to open a specific html page based on the notification you click. 这将根据您单击的通知打开特定的html页面。

I am not able to use it correctly. 我无法正确使用它。 Also blackberry support forms do not give reply or any sample for this. 另外,黑莓支持表对此也没有给出答复或任何示例。

Question I asked in Blackberry Support Forums 我在Blackberry支持论坛中提出的问题

I think there is a simpler way of achieving what you are trying to do. 我认为有一种更简单的方法可以实现您要完成的任务。 First of all allow me to point you to the notification sample: https://github.com/blackberry/BB10-WebWorks-Samples/blob/master/notify/ . 首先,请允许我指向通知示例: https : //github.com/blackberry/BB10-WebWorks-Samples/blob/master/notify/

To answer your specific query you need to bear in mind 2 things in the following order: 要回答您的特定查询,您需要记住以下两点:

(1). (1)。 The app needs to be invokable so you need to modify the config.xml and the index.html respectively: 该应用需要可调用,因此您需要分别修改config.xml和index.html:

config.xml config.xml

<rim:invoke-target id="com.myApp.entrypoint">
    <type>APPLICATION</type>
    <filter>
        <action>bb.action.OPEN</action>
        <mime-type>text/plain</mime-type>
    </filter>
</rim:invoke-target>

where "id" is your unique ID (ie. nobody else should be using that) 其中“ id”是您的唯一ID(即没有其他人可以使用该ID)

index.html or index.js index.html或index.js

document.addEventListener("invoked", onInvoked, false);

add the above after the system has fired the "deviceready" event. 在系统触发“ deviceready”事件后添加以上内容。 The "onInvoked" function will look like: “ onInvoked”功能如下所示:

function onInvoked(data) {
   var pageToOpen = data.URI;
   //do something with pageToOpen now
}

(2). (2)。 Your notification will need to have the attribute "payLoadURI" set to the html page that you want to open. 您的通知将需要将属性“ payLoadURI”设置为要打开的html页面。 I'm thinking It will be something like 我在想会像

local:///myPage.html

This "myPage.html" it's what your "pageToOpen" variable will receive and at that stage you can push the right HTML fragment to the top. 此“ myPage.html”就是您的“ pageToOpen”变量将接收的内容,在此阶段,您可以将正确的HTML片段推到顶部。

I hope it helps. 希望对您有所帮助。

PS this has been tested with WebWorks 2.0 so I would advise you to upgrade for a better experience. PS此产品已通过WebWorks 2.0进行了测试,因此我建议您进行升级以获得更好的体验。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM