From: Piotr Kosko Date: Mon, 20 Mar 2017 10:00:10 +0000 (+0100) Subject: [Notification] Template feature added X-Git-Tag: GitHub/PR#40/tizen-studio~198^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=17969a08f8e7615a14a307d32cc260cdc0a17de4;p=sdk%2Fonline-doc.git [Notification] Template feature added Change-Id: Ib8138589c0b14811f93674b5c56bc7a59007de8b Signed-off-by: Piotr Kosko --- diff --git a/org.tizen.guides/html/web/notification/notification_w.htm b/org.tizen.guides/html/web/notification/notification_w.htm index 322f756..2611e01 100644 --- a/org.tizen.guides/html/web/notification/notification_w.htm +++ b/org.tizen.guides/html/web/notification/notification_w.htm @@ -31,6 +31,7 @@
  • Creating Simple Notifications
  • Creating Progress Notifications
  • Managing Notifications
  • +
  • Managing Notification Templates
  • Related Info

    To display a notification, you need to create a Notification object (in mobile and wearable applications), or its subtype.

    @@ -204,6 +207,39 @@ tizen.notification.removeAll(); +

    Managing Notification templates

    + +

    Learning how to manage notification templates allows you to save a notification as a template and use it later to faster creation of new notifications based on the same pattern:

    +
      +
    1. To save a template:

      +
        +
      1. Create a "SIMPLE" or "PROGRESS" notification, which would be used as a template. There is no need to post it. +
        +// assume that myNotification is a valid tizen.StatusNotification object
        +var myNotification;
        +
      2. +
      3. To save the template, use saveNotificationAsTemplate() method of the NotificationManager interface (in mobile and wearable applications):

        +
        +try {
        +   var templateName = "importantNoti";
        +   tizen.notification.saveNotificationAsTemplate(templateName, myNotification);
        +} catch(e) {
        +   console.log("Error " + e.message + " occured");
        +}
        +
      4. +
    2. +
    3. To use the template for creation of new pre-set notification, use the createNotificationFromTemplate() method of the NotificationManager interface (in mobile and wearable applications):

      +
      +try {
      +   var newTemplateNotification = tizen.notification.createNotificationFromTemplate(templateName);
      +   console.log("Content of new notification: " + content);
      +} catch (e) {
      +   console.log("Error " + e.message + " occured");
      +}
      +
    4. +
    + + @@ -226,4 +262,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga - \ No newline at end of file + diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/notification.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/notification.html index 6144326..5f776c2 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/notification.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/notification.html @@ -24,15 +24,20 @@ For more information on the Notification features, see
  • 1. Type Definitions
  • @@ -70,14 +75,21 @@ For more information on the Notification features, see NotificationManager -void post (Notification notification)
    - void update (Notification notification)
    - void remove (NotificationId id)
    - void removeAll ()
    - Notification get (NotificationId id)
    - Notification[] getAll ()
    - void playLEDCustomEffect (long timeOn, long timeOff, DOMString color, LEDCustomFlags[] flags)
    - void stopLEDCustomEffect () + +
    void post (Notification notification)
    +
    void update (Notification notification)
    +
    void remove (NotificationId id)
    +
    void removeAll ()
    +
    +Notification get (NotificationId id)
    +
    +Notification[] getAll ()
    +
    void playLEDCustomEffect (long timeOn, long timeOff, DOMString color, LEDCustomFlags[] flags)
    +
    void stopLEDCustomEffect ()
    +
    void saveNotificationAsTemplate (DOMString name, Notification notification)
    +
    +Notification createNotificationFromTemplate (DOMString name)
    + Notification @@ -246,6 +258,10 @@ Notification API. void playLEDCustomEffect(long timeOn, long timeOff, DOMString color, LEDCustomFlags[] flags) raises(WebAPIException); void stopLEDCustomEffect() raises(WebAPIException); + + void saveNotificationAsTemplate(DOMString name, Notification notification) raises(WebAPIException); + + Notification createNotificationFromTemplate(DOMString name) raises(WebAPIException); };

    Since: @@ -729,6 +745,152 @@ try catch (e) {    console.log("Error Exception, error name: " + e.name + ", error message: " + e.message); + + + +

    +saveNotificationAsTemplate +
    +
    +
    + Saves a notification template to the notification database. +
    +
    void saveNotificationAsTemplate(DOMString name, Notification notification);
    +             
    +

    + Since: + 4.0 +

    +
    +

    +An application can save the created notification as a template for later reuse. +If the template has the same name as a saved one, the saved template will be overwritten. +

    +

    +A saved template can be loaded only by the application which saved it. +All templates are removed when the application package is uninstalled. +

    +
    +

    + Privilege level: + public +

    +

    + Privilege: + http://tizen.org/privilege/notification +

    +

    Remark : + The number of templates is limited to 10. When you try to add more than 10 templates, exception is thrown. +

    +
    +

    Parameters:

    +
      +
    • +name: + The name of template to be saved. +
    • +
    • +notification: + A notification to be saved as a template. +
    • +
    +
    +
    +

    Exceptions:

    +
    • WebAPIException
        +
      • + with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter. +

      • +
      • + with error type SecurityError, if the application does not have the privilege to call this method. +

      • +
      • + with error type QuotaExceededError, if the allowed number of templates is exceeded. +

      • +
      • + with error type AbortError, if the method cannot be completed because of any error. +

      • +
      +
    +
    +
    +

    Code example:

    +try {
    +    var notificationDict = {
    +                content : "This is a simple notification.",
    +                iconPath : "images/image1.jpg",
    +                soundPath : "music/Over the horizon.mp3",
    +                vibration : true
    +    };
    +
    +    var notification = new tizen.StatusNotification("SIMPLE",
    +                "Simple notification", notificationDict);
    +
    +    tizen.notification.saveNotificationAsTemplate("SIMPLE_TEMPLATE", notification);
    +} catch (err) {
    +    console.log(err.name + ": " + err.message);
    +}
    +
    +
    +
    +
    +createNotificationFromTemplate +
    +
    +
    + Creates notification based on previously created template. +
    +
    Notification createNotificationFromTemplate(DOMString name);
    +             
    +

    + Since: + 4.0 +

    +
    +

    +An application can load a saved template and post it. +An application can load only templates that it has saved. +

    +
    +

    + Privilege level: + public +

    +

    + Privilege: + http://tizen.org/privilege/notification +

    +
    +

    Parameters:

    +
      +
    • +name: + The name of template to be used as source of notification. +
    • +
    +
    +
    +

    Exceptions:

    +
    • WebAPIException
        +
      • + with error type SecurityError, if the application does not have the privilege to call this method. +

      • +
      • + with error type NotFoundError, if the method cannot find a template with given name. +

      • +
      • + with error type AbortError, if the method cannot be completed because of any error. +

      • +
      +
    +
    +
    +

    Code example:

    +/* the template with name "SIMPLE_TEMPLATE" should be previously created */
    +try {
    +    var notification = tizen.notification.createNotificationFromTemplate("SIMPLE_TEMPLATE");
    +} catch (err) {
    +     console.log(err.name + ": " + err.message);
     }
     
    @@ -1265,6 +1427,10 @@ If an application uses playLEDCustomEffect() or stopLEDCustomEffect(), declare t void playLEDCustomEffect(long timeOn, long timeOff, DOMString color, LEDCustomFlags[] flags) raises(WebAPIException); void stopLEDCustomEffect() raises(WebAPIException); + + void saveNotificationAsTemplate(DOMString name, Notification notification) raises(WebAPIException); + + Notification createNotificationFromTemplate(DOMString name) raises(WebAPIException); }; diff --git a/org.tizen.web.apireference/html/device_api/wearable/tizen/notification.html b/org.tizen.web.apireference/html/device_api/wearable/tizen/notification.html index 949317b..5243be1 100644 --- a/org.tizen.web.apireference/html/device_api/wearable/tizen/notification.html +++ b/org.tizen.web.apireference/html/device_api/wearable/tizen/notification.html @@ -25,13 +25,17 @@ For more information on the Notification features, see
  • 1. Type Definitions
  • @@ -67,12 +71,19 @@ For more information on the Notification features, see NotificationManager -void post (Notification notification)
    - void update (Notification notification)
    - void remove (NotificationId id)
    - void removeAll ()
    - Notification get (NotificationId id)
    - Notification[] getAll () + +
    void post (Notification notification)
    +
    void update (Notification notification)
    +
    void remove (NotificationId id)
    +
    void removeAll ()
    +
    +Notification get (NotificationId id)
    +
    +Notification[] getAll ()
    +
    void saveNotificationAsTemplate (DOMString name, Notification notification)
    +
    +Notification createNotificationFromTemplate (DOMString name)
    + Notification @@ -218,6 +229,9 @@ Notification API. Notification[] getAll() raises(WebAPIException); + void saveNotificationAsTemplate(DOMString name, Notification notification) raises(WebAPIException); + + Notification createNotificationFromTemplate(DOMString name) raises(WebAPIException); };

    Since: @@ -571,6 +585,151 @@ try catch (err) {    console.log(err.name + ": " + err.message); + + +

    +saveNotificationAsTemplate +
    +
    +
    + Saves a notification template to the notification database. +
    +
    void saveNotificationAsTemplate(DOMString name, Notification notification);
    +             
    +

    + Since: + 4.0 +

    +
    +

    +An application can save the created notification as a template for later reuse. +If the template has the same name as a saved one, the saved template will be overwritten. +

    +

    +A saved template can be loaded only by the application which saved it. +All templates are removed when the application package is uninstalled. +

    +
    +

    + Privilege level: + public +

    +

    + Privilege: + http://tizen.org/privilege/notification +

    +

    Remark : + The number of templates is limited to 10. When you try to add more than 10 templates, exception is thrown. +

    +
    +

    Parameters:

    +
      +
    • +name: + The name of template to be saved. +
    • +
    • +notification: + A notification to be saved as a template. +
    • +
    +
    +
    +

    Exceptions:

    +
    • WebAPIException
        +
      • + with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter. +

      • +
      • + with error type SecurityError, if the application does not have the privilege to call this method. +

      • +
      • + with error type QuotaExceededError, if the allowed number of templates is exceeded. +

      • +
      • + with error type AbortError, if the method cannot be completed because of any error. +

      • +
      +
    +
    +
    +

    Code example:

    +try {
    +    var notificationDict = {
    +                content : "This is a simple notification.",
    +                iconPath : "images/image1.jpg",
    +                soundPath : "music/Over the horizon.mp3",
    +                vibration : true
    +    };
    +
    +    var notification = new tizen.StatusNotification("SIMPLE",
    +                "Simple notification", notificationDict);
    +
    +    tizen.notification.saveNotificationAsTemplate("SIMPLE_TEMPLATE", notification);
    +} catch (err) {
    +    console.log(err.name + ": " + err.message);
    +}
    +
    +
    +
    +
    +createNotificationFromTemplate +
    +
    +
    + Creates notification based on previously created template. +
    +
    Notification createNotificationFromTemplate(DOMString name);
    +             
    +

    + Since: + 4.0 +

    +
    +

    +An application can load a saved template and post it. +An application can load only templates that it has saved. +

    +
    +

    + Privilege level: + public +

    +

    + Privilege: + http://tizen.org/privilege/notification +

    +
    +

    Parameters:

    +
      +
    • +name: + The name of template to be used as source of notification. +
    • +
    +
    +
    +

    Exceptions:

    +
    • WebAPIException
        +
      • + with error type SecurityError, if the application does not have the privilege to call this method. +

      • +
      • + with error type NotFoundError, if the method cannot find a template with given name. +

      • +
      • + with error type AbortError, if the method cannot be completed because of any error. +

      • +
      +
    +
    +
    +

    Code example:

    +/* the template with name "SIMPLE_TEMPLATE" should be previously created */
    +try {
    +    var notification = tizen.notification.createNotificationFromTemplate("SIMPLE_TEMPLATE");
    +} catch (err) {
    +     console.log(err.name + ": " + err.message);
     }
     
    @@ -1089,6 +1248,9 @@ By default, this attribute is set to null. Notification[] getAll() raises(WebAPIException); + void saveNotificationAsTemplate(DOMString name, Notification notification) raises(WebAPIException); + + Notification createNotificationFromTemplate(DOMString name) raises(WebAPIException); };