From: Piotr Kosko
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:
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);
Create the ApplicationControl
and StatusNotificationInit
instances needed for the StatusNotification
notification type:
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);
Add the alarm notification:
@@ -248,4 +250,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga