From a7b3c537edf83b8415716f930fd3fe518638c4db Mon Sep 17 00:00:00 2001 From: Gubolin Date: Mon, 8 Sep 2014 12:27:01 +0200 Subject: add notification blocks --- mobile.sh | 1 + objects.js | 9 +++++++++ threads.js | 14 ++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/mobile.sh b/mobile.sh index 81fa6f3..909f7e5 100755 --- a/mobile.sh +++ b/mobile.sh @@ -47,6 +47,7 @@ cordova plugin add org.apache.cordova.vibration cordova plugin add org.apache.cordova.device-motion cordova plugin add org.apache.cordova.device-orientation cordova plugin add org.apache.cordova.geolocation +cordova plugin add de.appplant.cordova.plugin.local-notification if [[ $1 == "android" ]] then diff --git a/objects.js b/objects.js index 49fafb5..100bd67 100644 --- a/objects.js +++ b/objects.js @@ -415,6 +415,11 @@ SpriteMorph.prototype.initBlocks = function () { spec: 'go back %n layers', defaults: [1] }, + doNotify: { + type: 'command', + category: 'looks', + spec: 'notification with title %s and content %s' + }, doScreenshot: { type: 'command', category: 'looks', @@ -1762,6 +1767,8 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('comeToFront')); blocks.push(block('goBack')); + blocks.push('-'); + blocks.push(block('doNotify')); // for debugging: /////////////// @@ -4905,6 +4912,8 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('show')); blocks.push(block('hide')); + blocks.push('-'); + blocks.push(block('doNotify')); // for debugging: /////////////// diff --git a/threads.js b/threads.js index 3e50686..7616b88 100644 --- a/threads.js +++ b/threads.js @@ -2189,6 +2189,20 @@ Process.prototype.reportTextSplit = function (string, delimiter) { return new List(str.split(del)); }; +// Process notification operations + +Process.prototype.doNotify = function (title, content) { + // TODO webkitNotification + if (window.plugin) { + if (window.plugin.notification) { + window.plugin.notification.local.add({ + message: content, + title: title + }); + } + } +}; + // Process debugging Process.prototype.alert = function (data) { -- cgit v1.3.1