From: Piotr Kosko Date: Wed, 30 Aug 2017 09:14:45 +0000 (+0200) Subject: [Alarm] Changed behaviour of getAlarmNotification X-Git-Tag: GitHub/PR#40/tizen-studio~33^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7b2c7b90709f6a13592f2573522b254ff6b30ac2;p=sdk%2Fonline-doc.git [Alarm] Changed behaviour of getAlarmNotification PS3: Studio content reviewed. PS4: Removed extra whitespace Change-Id: I1e856333035b2c906a49ca04b2afd323134a6153 Signed-off-by: Piotr Kosko --- diff --git a/org.tizen.guides/html/web/alarm/alarms_w.htm b/org.tizen.guides/html/web/alarm/alarms_w.htm index 30fb656..6b37a57 100644 --- a/org.tizen.guides/html/web/alarm/alarms_w.htm +++ b/org.tizen.guides/html/web/alarm/alarms_w.htm @@ -189,14 +189,14 @@ console.log('The alarm triggers ' + alarm.getRemainingSeconds() + ' seconds late

Managing Alarm Notifications in Mobile and Wearable Applications

Alarm notification is an alarm which, when triggered, automatically posts a notification. You can create alarm notifications with both AlarmAbsolute (in mobile and wearable applications) and AlarmRelative (in mobile and wearable applications) alarm types. The notification is shown in the status bar on the device.

-

To create an alarm notification with the AlarmRelative alarm type and StatusNotification notification type, where the alarm is periodic and the notification is posted after the alarm is triggered:

+

To create an alarm notification with the AlarmRelative alarm type and UserNotification notification type, where the alarm is periodic and the notification is posted after the alarm is triggered:

  1. Create an AlarmRelative object:

     /* Alarm triggers after 3 seconds and repeats every 3 hours */
     var alarm = new tizen.AlarmRelative(3, 3 * tizen.alarm.PERIOD_HOUR);
     
  2. -
  3. Create the ApplicationControl and StatusNotificationInit instances needed for the StatusNotification notification type:

    +
  4. Create the ApplicationControl and UserNotificationInit instances needed for the UserNotification notification type:

     /* Create ApplicationControl object */
     var appControl = new tizen.ApplicationControl('http://tizen.org/appcontrol/operation/default',
    @@ -204,13 +204,15 @@ var appControl = new tizen.ApplicationControl('http://tizen.org/appcontrol/opera
     /* You can add additional attibutes to the notification dictionary */
     var notificationDict = {
         content: 'This is a simple notification\'s content.',
    -    vibration: true,
    -    appId: tizen.application.getCurrentApplication().appInfo.id,
    -    appControl: appControl,
    +    actions: {
    +        vibration: true,
    +        appId: tizen.application.getCurrentApplication().appInfo.id,
    +        appControl: appControl
    +    },
     };
    -/* Create StatusNotification object */
    -var notification = new tizen.StatusNotification('SIMPLE', 'Simple notification\'s title',
    -                                                notificationDict);
    +/* Create UserNotification object */
    +var notification = new tizen.UserNotification('SIMPLE', 'Simple notification\'s title',
    +                                              notificationDict);
     
  5. Add the alarm notification:

    @@ -248,4 +250,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/alarm.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/alarm.html
    index 83254fb..a6f8ffd 100755
    --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/alarm.html
    +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/alarm.html
    @@ -67,13 +67,18 @@ For more information on the Alarm features, see AlarmManager
    -void add (Alarm alarm, ApplicationId applicationId, optional ApplicationControl? appControl)
    - void addAlarmNotification (Alarm alarm, Notification notification)
    - void remove (AlarmId id)
    - void removeAll ()
    - Alarm get (AlarmId id)
    - Notification getAlarmNotification (AlarmId id)
    - Alarm[] getAll () + +
    void add (Alarm alarm, ApplicationId applicationId, optional ApplicationControl? appControl)
    +
    void addAlarmNotification (Alarm alarm, Notification notification)
    +
    void remove (AlarmId id)
    +
    void removeAll ()
    + + +
    +Alarm[] getAll ()
    + Alarm @@ -81,11 +86,11 @@ For more information on the Alarm features, see AlarmRelative -long? getRemainingSeconds () + AlarmAbsolute -Date? getNextScheduledDate () + @@ -160,7 +165,7 @@ The tizen.alarm object allows access to the functionality of the Alarm Alarm get(AlarmId id) raises(WebAPIException); - Notification getAlarmNotification(AlarmId id) raises(WebAPIException); + UserNotification getAlarmNotification(AlarmId id) raises(WebAPIException); Alarm[] getAll() raises(WebAPIException); };
    @@ -362,13 +367,17 @@ For more information about the notification, see The

    Code example:

     /* Triggers an alarm notification on a given date/time */
     var alarm = new tizen.AlarmAbsolute(new Date(2017, 10, 4, 8, 0));
    -var notificationDict =
    +var notificationGroupDict =
     {
    -   content: "This is a simple notification.",
    -   iconPath: "images/image1.jpg",
    -   soundPath: "music/Over the horizon.mp3"
    +  content: "This is a simple user notification.",
    +  actions:
    +  {
    +    soundPath: "music/Over the horizon.mp3",
    +    vibration: true
    +  }
     };
    -var notification = new tizen.StatusNotification("SIMPLE", "Simple notification", notificationDict);
    +
    +var notification = new tizen.UserNotification("SIMPLE", "User notification", notificationGroupDict);
     
     tizen.alarm.addAlarmNotification(alarm, notification);
     console.log("Alarm notification added with id: " + alarm.id);
    @@ -559,9 +568,9 @@ console.log("The alarm will trigger at " + alarm.getNextScheduledDate());
     
     
    - Gets the notification to be posted when an alarm is triggered. Returned Notification is exactly the same like passed to method addAlarmNotification. + Gets the notification to be posted when an alarm is triggered. Returned UserNotification contains exactly the same data like passed to method addAlarmNotification.
    -
    Notification getAlarmNotification(AlarmId id);
    +
    UserNotification getAlarmNotification(AlarmId id);
                  

    Since: @@ -575,6 +584,10 @@ console.log("The alarm will trigger at " + alarm.getNextScheduledDate()); Privilege: http://tizen.org/privilege/alarm

    +

    Remark : + This method is designed to return only UserNotification objects, +even if the added alarm was using StatusNofitication. +

    Parameters:

      @@ -609,24 +622,28 @@ var date = new Date(); date.setHours(date.getHours() + 1); var alarm = new tizen.AlarmAbsolute(date); -var notificationDict = +var notificationGroupDict = { - content: "This is a simple notification.", - iconPath: "images/image1.jpg", - soundPath: "music/Over the horizon.mp3" + content: "This is a simple user notification.", + actions: + { + soundPath: "music/Over the horizon.mp3", + vibration: true + } }; -var notification = new tizen.StatusNotification("SIMPLE", "Simple notification", notificationDict); + +var notification = new tizen.UserNotification("SIMPLE", "User notification", notificationGroupDict); /* Adds an alarm */ tizen.alarm.addAlarmNotification(alarm, notification); /* Gets a notification */ var notification = tizen.alarm.getAlarmNotification(alarm.id); -console.log("Notification title: " + notification.title + ", content: " + notification.content); +console.log("User Notification title: " + notification.title + ", content: " + notification.content);
    -

    Output example:

     Notification title: Simple notification, content: This is a simple notification.
    +

    Output example:

     User Notification title: User notification, content: This is a simple user notification.
      
    @@ -837,8 +854,6 @@ console.log("remaining time is " + sec); interface AlarmAbsolute : Alarm { readonly attribute Date date; - readonly attribute long? period; - readonly attribute ByDayValue[] daysOfTheWeek; Date? getNextScheduledDate() raises(WebAPIException); @@ -1047,8 +1062,6 @@ console.log("next scheduled time is " + date); interface AlarmAbsolute : Alarm { readonly attribute Date date; - readonly attribute long? period; - readonly attribute ByDayValue[] daysOfTheWeek; Date? getNextScheduledDate() raises(WebAPIException); diff --git a/org.tizen.web.apireference/html/device_api/wearable/tizen/alarm.html b/org.tizen.web.apireference/html/device_api/wearable/tizen/alarm.html index f9fe271..406ba68 100755 --- a/org.tizen.web.apireference/html/device_api/wearable/tizen/alarm.html +++ b/org.tizen.web.apireference/html/device_api/wearable/tizen/alarm.html @@ -67,13 +67,18 @@ For more information on the Alarm features, see AlarmManager -void add (Alarm alarm, ApplicationId applicationId, optional ApplicationControl? appControl)
    - void addAlarmNotification (Alarm alarm, Notification notification)
    - void remove (AlarmId id)
    - void removeAll ()
    - Alarm get (AlarmId id)
    - Notification getAlarmNotification (AlarmId id)
    - Alarm[] getAll () + +
    void add (Alarm alarm, ApplicationId applicationId, optional ApplicationControl? appControl)
    +
    void addAlarmNotification (Alarm alarm, Notification notification)
    +
    void remove (AlarmId id)
    +
    void removeAll ()
    + + +
    +Alarm[] getAll ()
    + Alarm @@ -81,11 +86,11 @@ For more information on the Alarm features, see AlarmRelative -long? getRemainingSeconds () + AlarmAbsolute -Date? getNextScheduledDate () + @@ -160,7 +165,7 @@ The tizen.alarm object allows access to the functionality of the Alarm Alarm get(AlarmId id) raises(WebAPIException); - Notification getAlarmNotification(AlarmId id) raises(WebAPIException); + UserNotification getAlarmNotification(AlarmId id) raises(WebAPIException); Alarm[] getAll() raises(WebAPIException); };
    @@ -362,13 +367,17 @@ For more information about the notification, see The

    Code example:

     /* Triggers an alarm notification on a given date/time */
     var alarm = new tizen.AlarmAbsolute(new Date(2017, 10, 4, 8, 0));
    -var notificationDict =
    +var notificationGroupDict =
     {
    -   content: "This is a simple notification.",
    -   iconPath: "images/image1.jpg",
    -   soundPath: "music/Over the horizon.mp3"
    +  content: "This is a simple user notification.",
    +  actions:
    +  {
    +    soundPath: "music/Over the horizon.mp3",
    +    vibration: true
    +  }
     };
    -var notification = new tizen.StatusNotification("SIMPLE", "Simple notification", notificationDict);
    +
    +var notification = new tizen.UserNotification("SIMPLE", "User notification", notificationGroupDict);
     
     tizen.alarm.addAlarmNotification(alarm, notification);
     console.log("Alarm notification added with id: " + alarm.id);
    @@ -559,9 +568,9 @@ console.log("The alarm will trigger at " + alarm.getNextScheduledDate());
     
     
    - Gets the notification to be posted when an alarm is triggered. Returned Notification is exactly the same like passed to method addAlarmNotification. + Gets the notification to be posted when an alarm is triggered. Returned UserNotification contains exactly the same data like passed to method addAlarmNotification.
    -
    Notification getAlarmNotification(AlarmId id);
    +
    UserNotification getAlarmNotification(AlarmId id);
                  

    Since: @@ -575,6 +584,10 @@ console.log("The alarm will trigger at " + alarm.getNextScheduledDate()); Privilege: http://tizen.org/privilege/alarm

    +

    Remark : + This method is designed to return only UserNotification objects, +even if the added alarm was using StatusNofitication. +

    Parameters:

      @@ -609,24 +622,28 @@ var date = new Date(); date.setHours(date.getHours() + 1); var alarm = new tizen.AlarmAbsolute(date); -var notificationDict = +var notificationGroupDict = { - content: "This is a simple notification.", - iconPath: "images/image1.jpg", - soundPath: "music/Over the horizon.mp3" + content: "This is a simple user notification.", + actions: + { + soundPath: "music/Over the horizon.mp3", + vibration: true + } }; -var notification = new tizen.StatusNotification("SIMPLE", "Simple notification", notificationDict); + +var notification = new tizen.UserNotification("SIMPLE", "User notification", notificationGroupDict); /* Adds an alarm */ tizen.alarm.addAlarmNotification(alarm, notification); /* Gets a notification */ var notification = tizen.alarm.getAlarmNotification(alarm.id); -console.log("Notification title: " + notification.title + ", content: " + notification.content); +console.log("User Notification title: " + notification.title + ", content: " + notification.content);
    -

    Output example:

     Notification title: Simple notification, content: This is a simple notification.
    +

    Output example:

     User Notification title: User notification, content: This is a simple user notification.
      
    @@ -837,8 +854,6 @@ console.log("remaining time is " + sec); interface AlarmAbsolute : Alarm { readonly attribute Date date; - readonly attribute long? period; - readonly attribute ByDayValue[] daysOfTheWeek; Date? getNextScheduledDate() raises(WebAPIException); @@ -1047,8 +1062,6 @@ console.log("next scheduled time is " + date); interface AlarmAbsolute : Alarm { readonly attribute Date date; - readonly attribute long? period; - readonly attribute ByDayValue[] daysOfTheWeek; Date? getNextScheduledDate() raises(WebAPIException);