Permalink
Browse files

adds HTML5 notification sample app

  • Loading branch information...
1 parent 6c63d84 commit b88cb6e9f6cb53663bbb72525380e2f4d935e3f6 @haahmad haahmad committed Sep 27, 2012
View
@@ -0,0 +1,45 @@
+# HTML5 Notification Sample Application
+
+Sample applications that demonstrate how to use the HTML5 Notification API for the Blackberry 10 WebWorks SDK
+
+**Tested On**
+
+* BlackBerry 10.0.9
+
+**Author(s)**
+
+* [Hasan Ahmad](https://github.com/haahmad)
+
+**Dependencies**
+
+1. [jquery.mobile-1.1.0.min.js, jquery.mobile-1.1.0.min.css, jquery-1.7.1.min.js ](http://www.jquerymobile.com/) The jQuery Mobile Framework
+
+**To contribute code to this repository you must be [signed up as an official contributor](http://blackberry.github.com/howToContribute.html).**
+
+## How to Build
+
+1. Clone the repo to your local machine
+2. Use Using the **[Ripple Mobile Emulator](http://developer.blackberry.com/html5/download)** and either the **[BlackBerry WebWorks SDK for Smartphone](http://developer.blackberry.com/html5/download)** or the **[BlackBerry WebWorks SDK for Tablet OS](http://developer.blackberry.com/html5/download)**, package the contents of your local **BB10-WebWorks-Samples/notify** folder into a BlackBerry application.
+
+## Troubleshooting
+
+## More Info
+
+* [BlackBerry HTML5 WebWorks](https://bdsc.webapps.blackberry.com/html5/) - Downloads, Getting Started guides, samples, code signing keys.
+* [BlackBerry WebWorks Development Guides] (https://bdsc.webapps.blackberry.com/html5/documentation)
+* [BlackBerry WebWorks Community Forums](http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/bd-p/browser_dev)
+* [BlackBerry Open Source WebWorks Contributions Forums](http://supportforums.blackberry.com/t5/BlackBerry-WebWorks/bd-p/ww_con)
+
+## Contributing Changes
+
+Please see the [README](https://github.com/blackberry/BB10-WebWorks-Samples) of the BB10-WebWorks-Samples repository for instructions on how to add new Samples or make modifications to existing Samples.
+
+
+## Bug Reporting and Feature Requests
+
+If you find a bug in a Sample, or have an enhancement request, simply file an [Issue](https://github.com/blackberry/BB10-WebWorks-Samples/issues) for the Sample and send a message (via github messages) to the Sample Author(s) to let them know that you have filed an [Issue](https://github.com/blackberry/BB10-WebWorks-Samples/issues).
+
+
+## Disclaimer
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Copyright 2010-2012 Research In Motion Limited.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<widget xmlns=" http://www.w3.org/ns/widgets"
+ xmlns:rim="http://www.blackberry.com/ns/widgets"
+ version="1.0.0"
+ id="notifySample">
+ <name>Notification Sample</name>
+ <content src="local:///index.htm"/>
+ <author>Research In Motion Ltd.</author>
+ <license href="http://www.apache.org/licenses/LICENSE-2.0">
+ Licensed under the Apache License, Version 2.0 (the "License");
+ #you may not use this file except in compliance with the License.
+ #You may obtain a copy of the License at
+ #
+ #http://www.apache.org/licenses/LICENSE-2.0
+ #
+ #Unless required by applicable law or agreed to in writing, software
+ #distributed under the License is distributed on an "AS IS" BASIS,
+ #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ #See the License for the specific language governing permissions and limitations under the License.
+ </license>
+
+ <feature id="blackberry.invoked" required="true" version="1.0.0.0" />
+ <feature id="blackberry.invoke" required="true" version="1.0.0.0" />
+
+ <rim:invoke-target id="notifyTest">
+ <type>APPLICATION</type>
+ <filter>
+ <action>bb.action.OPEN</action>
+ <mime-type>text/plain</mime-type>
+ </filter>
+ </rim:invoke-target>
+
+ <rim:permissions>
+ <rim:permit>post_notification</rim:permit>
+ </rim:permissions>
+
+</widget>
View
@@ -0,0 +1,128 @@
+<!DOCTYPE html>
+<!--
+* Copyright 2012 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+-->
+<!DOCTYPE html>
+<head>
+ <title>notification sample app</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <script src="webworks-1.0.2.9.js"></script>
+ <script src="jquery/jquery-1.7.1.min.js"></script>
+ <script src="jquery/jquery.mobile-1.1.0.min.js"></script>
+ <link rel="stylesheet" type="text/css" href="jquery/jquery.mobile-1.1.0.min.css" />
+ <script>
+ function ready() {
+ console.log("ready start");
+
+ blackberry.event.addEventListener("invoked", invokeHandler);
+
+ document.getElementById("b1").onclick = button1;
+ document.getElementById("b2").onclick = button2;
+ document.getElementById("b3").onclick = button3;
+ document.getElementById("b4").onclick = button4;
+ document.getElementById("b5").onclick = button5;
+ document.getElementById("b6").onclick = button6;
+ document.getElementById("b7").onclick = button7;
+ }
+
+ function populateInvokeElement(element, data) {
+ element.innerHTML += '<h5>Handler begin</h5>';
+ element.innerHTML += '<p>Target: ' + data.target + '</p>';
+ element.innerHTML += '<p>Action: ' + data.action + '</p>';
+ element.innerHTML += '<p>Type: ' + data.type + '</p>';
+ element.innerHTML += '<p>Data: ' + data.data + '</p>';
+ element.innerHTML += '<p>URI: ' + data.uri + '</p>';
+ element.innerHTML += '<h5>Handler end</h5>';
+ }
+
+ function invokeHandler(invokeData) {
+ var invokeDataElement = document.createElement("div");
+ populateInvokeElement(invokeDataElement, invokeData);
+ document.getElementById("log").appendChild(invokeDataElement);
+ }
+
+ function button1 () {
+ var n = new Notification("simple notification");
+ console.log(n);
+ }
+
+ function button2 () {
+ var n = new Notification("Title", { 'body' : "Body", 'tag': "Tag" });
+ console.log(n);
+ }
+
+ function button3 () {
+ var n = new Notification("onShow", {
+ 'onshow' : function () {
+ alert("onShow");
+ },
+ 'onerror' : function () {
+ alert("onError");
+ }
+ });
+ console.log(n);
+ }
+
+ function button4 () {
+ var n = new Notification("button4", {
+ 'target' : "notifyTest",
+ 'targetAction' : "bb.action.OPEN",
+ 'payloadURI' : "http://www.blackberry.com",
+ 'payloadType' : "text/html"
+ });
+ console.log(n);
+ }
+
+ function button5 () {
+ var n = new Notification("button5", {
+ 'targetAction' : "bb.action.NEWACTION",
+ });
+ console.log(n);
+ }
+
+ function button6 () {
+ var n = new Notification("button6");
+ console.log(n);
+ setTimeout(n.close(), 2000);
+ }
+
+ function button7 () {
+ var n = new Notification("button7", { 'tag': "Tag" });
+ console.log(n);
+ Notification.remove("Tag");
+ }
+
+
+ window.addEventListener("load", function () {
+ document.addEventListener("webworksready", ready);
+ }, false);
+ </script>
+</head>
+<body>
+ <h2>HTML5 Notification API</h2>
+
+ <button id="b1">Simple Notify</button><br />
+ <button id="b2">Notify with title, body and tag</button><br />
+ <button id="b3">Notify onShow callback</button><br />
+ <button id="b4">Notify with invoke paramters</button><br />
+ <button id="b5">Notify with invoke paramters 2</button><br />
+ <button id="b6">Notify then close after 2 seconds</button><br />
+ <button id="b7">Notify with tag then remove</button><br />
+
+ <div id=log>
+ <h3>onInvoked Log</h3>
+ </div>
+
+</body>
Oops, something went wrong. Retry.

0 comments on commit b88cb6e

Please sign in to comment.