<li><a href="#create">Creating Simple Notifications</a></li>
<li><a href="#progress">Creating Progress Notifications</a></li>
<li><a href="#manage">Managing Notifications</a></li>
+ <li><a href="#templates">Managing Notification Templates</a></li>
</ul>
<p class="toc-title">Related Info</p>
<ul class="toc">
<p>You can <a href="#progress">create a progress notification</a> that informs the user about the progress of an activity.</p></li>
<li>Managing notifications
<p>You can <a href="#manage">retrieve, update, and remove posted notifications</a>.</p></li>
+ <li>Managing Notification templates
+ <p>You can <a href="#templates">save templates and create notification</a> based on existing template.</p></li>
</ul>
<p>To display a notification, you need to create a <code>Notification</code> object (in <a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/notification.html#Notification">mobile</a> and <a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/notification.html#Notification">wearable</a> applications), or its subtype. </p>
</ol></li>
</ol>
+<h2 id="templates" name="templates">Managing Notification templates</h2>
+
+<p>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:</p>
+ <ol>
+ <li><p>To save a template:</p>
+ <ol type="a">
+ <li>Create a <a href="#create">"SIMPLE"</a> or <a href="#progress">"PROGRESS"</a> notification, which would be used as a template. There is no need to post it.
+<pre class="prettyprint">
+// assume that myNotification is a valid tizen.StatusNotification object
+var myNotification;
+</pre></li>
+ <li><p>To save the template, use <code>saveNotificationAsTemplate()</code> method of the <code>NotificationManager</code> interface (in <a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/notification.html#NotificationManager::saveNotificationAsTemplate">mobile</a> and <a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/notification.html#NotificationManager::saveNotificationAsTemplate">wearable</a> applications):</p>
+<pre class="prettyprint">
+try {
+ var templateName = "importantNoti";
+ tizen.notification.saveNotificationAsTemplate(templateName, myNotification);
+} catch(e) {
+ console.log("Error " + e.message + " occured");
+}
+</pre></li>
+ </ol></li>
+ <li><p>To use the template for creation of new pre-set notification, use the <code>createNotificationFromTemplate()</code> method of the <code>NotificationManager</code> interface (in <a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/notification.html#NotificationManager::createNotificationFromTemplate">mobile</a> and <a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/notification.html#NotificationManager::createNotificationFromTemplate">wearable</a> applications):</p>
+<pre class="prettyprint">
+try {
+ var newTemplateNotification = tizen.notification.createNotificationFromTemplate(templateName);
+ console.log("Content of new notification: " + content);
+} catch (e) {
+ console.log("Error " + e.message + " occured");
+}
+</pre></li>
+ </ol></li>
+ </ol>
+
<script type="text/javascript" src="../../scripts/jquery.zclip.min.js"></script>
<script type="text/javascript" src="../../scripts/showhide.js"></script>
</div></div></div>
</script>
</body>
-</html>
\ No newline at end of file
+</html>
<h2>Table of Contents</h2>
<ul class="toc">
<li>1. <a href="#typedefs-section">Type Definitions</a><ul class="toc">
-<li>1.1. <a href="#NotificationId">NotificationId</a>
+<li>
+ 1.1. <a href="#NotificationId">NotificationId</a>
</li>
-<li>1.2. <a href="#NotificationType">NotificationType</a>
+<li>
+ 1.2. <a href="#NotificationType">NotificationType</a>
</li>
-<li>1.3. <a href="#StatusNotificationType">StatusNotificationType</a>
+<li>
+ 1.3. <a href="#StatusNotificationType">StatusNotificationType</a>
</li>
-<li>1.4. <a href="#NotificationProgressType">NotificationProgressType</a>
+<li>
+ 1.4. <a href="#NotificationProgressType">NotificationProgressType</a>
</li>
-<li>1.5. <a href="#LEDCustomFlags">LEDCustomFlags</a>
+<li>
+ 1.5. <a href="#LEDCustomFlags">LEDCustomFlags</a>
</li>
</ul>
</li>
</tr>
<tr>
<td><a href="#NotificationManager">NotificationManager</a></td>
-<td>void <a href="#NotificationManager::post">post</a> (<a href="#Notification">Notification</a> notification)<br>
- void <a href="#NotificationManager::update">update</a> (<a href="#Notification">Notification</a> notification)<br>
- void <a href="#NotificationManager::remove">remove</a> (<a href="#NotificationId">NotificationId</a> id)<br>
- void <a href="#NotificationManager::removeAll">removeAll</a> ()<br>
- <a href="#Notification">Notification</a> <a href="#NotificationManager::get">get</a> (<a href="#NotificationId">NotificationId</a> id)<br>
- <a href="#Notification">Notification</a>[] <a href="#NotificationManager::getAll">getAll</a> ()<br>
- void <a href="#NotificationManager::playLEDCustomEffect">playLEDCustomEffect</a> (long timeOn, long timeOff, DOMString color, <a href="#LEDCustomFlags">LEDCustomFlags</a>[] flags)<br>
- void <a href="#NotificationManager::stopLEDCustomEffect">stopLEDCustomEffect</a> ()</td>
+<td>
+<div>void <a href="#NotificationManager::post">post</a> (<a href="#Notification">Notification</a> notification)</div>
+<div>void <a href="#NotificationManager::update">update</a> (<a href="#Notification">Notification</a> notification)</div>
+<div>void <a href="#NotificationManager::remove">remove</a> (<a href="#NotificationId">NotificationId</a> id)</div>
+<div>void <a href="#NotificationManager::removeAll">removeAll</a> ()</div>
+<div>
+<a href="#Notification">Notification</a> <a href="#NotificationManager::get">get</a> (<a href="#NotificationId">NotificationId</a> id)</div>
+<div>
+<a href="#Notification">Notification</a>[] <a href="#NotificationManager::getAll">getAll</a> ()</div>
+<div>void <a href="#NotificationManager::playLEDCustomEffect">playLEDCustomEffect</a> (long timeOn, long timeOff, DOMString color, <a href="#LEDCustomFlags">LEDCustomFlags</a>[] flags)</div>
+<div>void <a href="#NotificationManager::stopLEDCustomEffect">stopLEDCustomEffect</a> ()</div>
+<div>void <a href="#NotificationManager::saveNotificationAsTemplate">saveNotificationAsTemplate</a> (DOMString name, <a href="#Notification">Notification</a> notification)</div>
+<div>
+<a href="#Notification">Notification</a> <a href="#NotificationManager::createNotificationFromTemplate">createNotificationFromTemplate</a> (DOMString name)</div>
+</td>
</tr>
<tr>
<td><a href="#Notification">Notification</a></td>
void playLEDCustomEffect(long timeOn, long timeOff, DOMString color, <a href="#LEDCustomFlags">LEDCustomFlags</a>[] flags) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
void stopLEDCustomEffect() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
+
+ void saveNotificationAsTemplate(DOMString name, <a href="#Notification">Notification</a> notification) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
+
+ <a href="#Notification">Notification</a> createNotificationFromTemplate(DOMString name) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
};</pre>
<p><span class="version">
Since: </span>
catch (e)
{
console.log("Error Exception, error name: " + e.name + ", error message: " + e.message);
+</pre>
+</div>
+</dd>
+<dt class="method" id="NotificationManager::saveNotificationAsTemplate">
+<a class="backward-compatibility-anchor" name="::Notification::NotificationManager::saveNotificationAsTemplate"></a><code><b><span class="methodName">saveNotificationAsTemplate</span></b></code>
+</dt>
+<dd>
+<div class="brief">
+ Saves a notification template to the notification database.
+ </div>
+<div class="synopsis"><pre class="signature prettyprint">void saveNotificationAsTemplate(DOMString name, <a href="#Notification">Notification</a> notification);
+ </pre></div>
+<p><span class="version">
+ Since: </span>
+ 4.0
+ </p>
+<div class="description">
+ <p>
+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.
+ </p>
+ <p>
+A saved template can be loaded only by the application which saved it.
+All templates are removed when the application package is uninstalled.
+ </p>
+ </div>
+<p><span class="privilegelevel">
+ Privilege level: </span>
+ public
+ </p>
+<p><span class="privilege">
+ Privilege: </span>
+ http://tizen.org/privilege/notification
+ </p>
+<p><span class="remark"> Remark : </span>
+ The number of templates is limited to 10. When you try to add more than 10 templates, exception is thrown.
+ </p>
+<div class="parameters">
+<p><span class="param">Parameters:</span></p>
+<ul>
+ <li class="param">
+<span class="name">name</span>:
+ The name of template to be saved.
+ </li>
+ <li class="param">
+<span class="name">notification</span>:
+ A notification to be saved as a template.
+ </li>
+ </ul>
+</div>
+<div class="exceptionlist">
+<p><span class="except">Exceptions:</span></p>
+ <ul class="exception"><li>WebAPIException<ul>
+<li class="list"><p>
+ with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
+ </p></li>
+<li class="list"><p>
+ with error type SecurityError, if the application does not have the privilege to call this method.
+ </p></li>
+<li class="list"><p>
+ with error type QuotaExceededError, if the allowed number of templates is exceeded.
+ </p></li>
+<li class="list"><p>
+ with error type AbortError, if the method cannot be completed because of any error.
+ </p></li>
+</ul>
+</li></ul>
+ </div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
+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);
+}
+</pre>
+</div>
+</dd>
+<dt class="method" id="NotificationManager::createNotificationFromTemplate">
+<a class="backward-compatibility-anchor" name="::Notification::NotificationManager::createNotificationFromTemplate"></a><code><b><span class="methodName">createNotificationFromTemplate</span></b></code>
+</dt>
+<dd>
+<div class="brief">
+ Creates notification based on previously created template.
+ </div>
+<div class="synopsis"><pre class="signature prettyprint"><a href="#Notification">Notification</a> createNotificationFromTemplate(DOMString name);
+ </pre></div>
+<p><span class="version">
+ Since: </span>
+ 4.0
+ </p>
+<div class="description">
+ <p>
+An application can load a saved template and post it.
+An application can load only templates that it has saved.
+ </p>
+ </div>
+<p><span class="privilegelevel">
+ Privilege level: </span>
+ public
+ </p>
+<p><span class="privilege">
+ Privilege: </span>
+ http://tizen.org/privilege/notification
+ </p>
+<div class="parameters">
+<p><span class="param">Parameters:</span></p>
+<ul>
+ <li class="param">
+<span class="name">name</span>:
+ The name of template to be used as source of notification.
+ </li>
+ </ul>
+</div>
+<div class="exceptionlist">
+<p><span class="except">Exceptions:</span></p>
+ <ul class="exception"><li>WebAPIException<ul>
+<li class="list"><p>
+ with error type SecurityError, if the application does not have the privilege to call this method.
+ </p></li>
+<li class="list"><p>
+ with error type NotFoundError, if the method cannot find a template with given name.
+ </p></li>
+<li class="list"><p>
+ with error type AbortError, if the method cannot be completed because of any error.
+ </p></li>
+</ul>
+</li></ul>
+ </div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
+/* 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);
}
</pre>
</div>
void playLEDCustomEffect(long timeOn, long timeOff, DOMString color, <a href="#LEDCustomFlags">LEDCustomFlags</a>[] flags) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
void stopLEDCustomEffect() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
+
+ void saveNotificationAsTemplate(DOMString name, <a href="#Notification">Notification</a> notification) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
+
+ <a href="#Notification">Notification</a> createNotificationFromTemplate(DOMString name) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
};
<h2>Table of Contents</h2>
<ul class="toc">
<li>1. <a href="#typedefs-section">Type Definitions</a><ul class="toc">
-<li>1.1. <a href="#NotificationId">NotificationId</a>
+<li>
+ 1.1. <a href="#NotificationId">NotificationId</a>
</li>
-<li>1.2. <a href="#NotificationType">NotificationType</a>
+<li>
+ 1.2. <a href="#NotificationType">NotificationType</a>
</li>
-<li>1.3. <a href="#StatusNotificationType">StatusNotificationType</a>
+<li>
+ 1.3. <a href="#StatusNotificationType">StatusNotificationType</a>
</li>
-<li>1.4. <a href="#NotificationProgressType">NotificationProgressType</a>
+<li>
+ 1.4. <a href="#NotificationProgressType">NotificationProgressType</a>
</li>
</ul>
</li>
</tr>
<tr>
<td><a href="#NotificationManager">NotificationManager</a></td>
-<td>void <a href="#NotificationManager::post">post</a> (<a href="#Notification">Notification</a> notification)<br>
- void <a href="#NotificationManager::update">update</a> (<a href="#Notification">Notification</a> notification)<br>
- void <a href="#NotificationManager::remove">remove</a> (<a href="#NotificationId">NotificationId</a> id)<br>
- void <a href="#NotificationManager::removeAll">removeAll</a> ()<br>
- <a href="#Notification">Notification</a> <a href="#NotificationManager::get">get</a> (<a href="#NotificationId">NotificationId</a> id)<br>
- <a href="#Notification">Notification</a>[] <a href="#NotificationManager::getAll">getAll</a> ()</td>
+<td>
+<div>void <a href="#NotificationManager::post">post</a> (<a href="#Notification">Notification</a> notification)</div>
+<div>void <a href="#NotificationManager::update">update</a> (<a href="#Notification">Notification</a> notification)</div>
+<div>void <a href="#NotificationManager::remove">remove</a> (<a href="#NotificationId">NotificationId</a> id)</div>
+<div>void <a href="#NotificationManager::removeAll">removeAll</a> ()</div>
+<div>
+<a href="#Notification">Notification</a> <a href="#NotificationManager::get">get</a> (<a href="#NotificationId">NotificationId</a> id)</div>
+<div>
+<a href="#Notification">Notification</a>[] <a href="#NotificationManager::getAll">getAll</a> ()</div>
+<div>void <a href="#NotificationManager::saveNotificationAsTemplate">saveNotificationAsTemplate</a> (DOMString name, <a href="#Notification">Notification</a> notification)</div>
+<div>
+<a href="#Notification">Notification</a> <a href="#NotificationManager::createNotificationFromTemplate">createNotificationFromTemplate</a> (DOMString name)</div>
+</td>
</tr>
<tr>
<td><a href="#Notification">Notification</a></td>
<a href="#Notification">Notification</a>[] getAll() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
+ void saveNotificationAsTemplate(DOMString name, <a href="#Notification">Notification</a> notification) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
+
+ <a href="#Notification">Notification</a> createNotificationFromTemplate(DOMString name) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
};</pre>
<p><span class="version">
Since: </span>
catch (err)
{
console.log(err.name + ": " + err.message);
+</pre>
+</div>
+<dt class="method" id="NotificationManager::saveNotificationAsTemplate">
+<a class="backward-compatibility-anchor" name="::Notification::NotificationManager::saveNotificationAsTemplate"></a><code><b><span class="methodName">saveNotificationAsTemplate</span></b></code>
+</dt>
+<dd>
+<div class="brief">
+ Saves a notification template to the notification database.
+ </div>
+<div class="synopsis"><pre class="signature prettyprint">void saveNotificationAsTemplate(DOMString name, <a href="#Notification">Notification</a> notification);
+ </pre></div>
+<p><span class="version">
+ Since: </span>
+ 4.0
+ </p>
+<div class="description">
+ <p>
+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.
+ </p>
+ <p>
+A saved template can be loaded only by the application which saved it.
+All templates are removed when the application package is uninstalled.
+ </p>
+ </div>
+<p><span class="privilegelevel">
+ Privilege level: </span>
+ public
+ </p>
+<p><span class="privilege">
+ Privilege: </span>
+ http://tizen.org/privilege/notification
+ </p>
+<p><span class="remark"> Remark : </span>
+ The number of templates is limited to 10. When you try to add more than 10 templates, exception is thrown.
+ </p>
+<div class="parameters">
+<p><span class="param">Parameters:</span></p>
+<ul>
+ <li class="param">
+<span class="name">name</span>:
+ The name of template to be saved.
+ </li>
+ <li class="param">
+<span class="name">notification</span>:
+ A notification to be saved as a template.
+ </li>
+ </ul>
+</div>
+<div class="exceptionlist">
+<p><span class="except">Exceptions:</span></p>
+ <ul class="exception"><li>WebAPIException<ul>
+<li class="list"><p>
+ with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
+ </p></li>
+<li class="list"><p>
+ with error type SecurityError, if the application does not have the privilege to call this method.
+ </p></li>
+<li class="list"><p>
+ with error type QuotaExceededError, if the allowed number of templates is exceeded.
+ </p></li>
+<li class="list"><p>
+ with error type AbortError, if the method cannot be completed because of any error.
+ </p></li>
+</ul>
+</li></ul>
+ </div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
+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);
+}
+</pre>
+</div>
+</dd>
+<dt class="method" id="NotificationManager::createNotificationFromTemplate">
+<a class="backward-compatibility-anchor" name="::Notification::NotificationManager::createNotificationFromTemplate"></a><code><b><span class="methodName">createNotificationFromTemplate</span></b></code>
+</dt>
+<dd>
+<div class="brief">
+ Creates notification based on previously created template.
+ </div>
+<div class="synopsis"><pre class="signature prettyprint"><a href="#Notification">Notification</a> createNotificationFromTemplate(DOMString name);
+ </pre></div>
+<p><span class="version">
+ Since: </span>
+ 4.0
+ </p>
+<div class="description">
+ <p>
+An application can load a saved template and post it.
+An application can load only templates that it has saved.
+ </p>
+ </div>
+<p><span class="privilegelevel">
+ Privilege level: </span>
+ public
+ </p>
+<p><span class="privilege">
+ Privilege: </span>
+ http://tizen.org/privilege/notification
+ </p>
+<div class="parameters">
+<p><span class="param">Parameters:</span></p>
+<ul>
+ <li class="param">
+<span class="name">name</span>:
+ The name of template to be used as source of notification.
+ </li>
+ </ul>
+</div>
+<div class="exceptionlist">
+<p><span class="except">Exceptions:</span></p>
+ <ul class="exception"><li>WebAPIException<ul>
+<li class="list"><p>
+ with error type SecurityError, if the application does not have the privilege to call this method.
+ </p></li>
+<li class="list"><p>
+ with error type NotFoundError, if the method cannot find a template with given name.
+ </p></li>
+<li class="list"><p>
+ with error type AbortError, if the method cannot be completed because of any error.
+ </p></li>
+</ul>
+</li></ul>
+ </div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
+/* 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);
}
</pre>
</div>
<a href="#Notification">Notification</a>[] getAll() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
+ void saveNotificationAsTemplate(DOMString name, <a href="#Notification">Notification</a> notification) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
+
+ <a href="#Notification">Notification</a> createNotificationFromTemplate(DOMString name) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
};