For more information about how to use Badge API, see Badge Guide.
Since: 2.3
Interface | Method |
---|---|
BadgeManagerObject | |
BadgeManager | void setBadgeCount (ApplicationId appId, long count) long getBadgeCount (ApplicationId appId) void addChangeListener (ApplicationId[] appIdList, BadgeChangeCallback successCallback) void removeChangeListener (ApplicationId[] appIdList) |
BadgeChangeCallback | void onsuccess (ApplicationId appId, long count) |
[NoInterfaceObject] interface BadgeManagerObject { readonly attribute BadgeManager badge; };
Tizen implements BadgeManagerObject;
Since: 2.3
There is a tizen.badge object that allows accessing the functionality of the Badge API.
[NoInterfaceObject] interface BadgeManager { readonly attribute long maxBadgeCount; void setBadgeCount(ApplicationId appId, long count) raises(WebAPIException); long getBadgeCount(ApplicationId appId) raises(WebAPIException); void addChangeListener(ApplicationId[]appIdList, BadgeChangeCallback successCallback) raises(WebAPIException); void removeChangeListener(ApplicationId[] appIdList) raises(WebAPIException); };
Since: 2.3
Since: 2.3
setBadgeCount
void setBadgeCount(ApplicationId appId, long count);
Since: 2.3
Privilege level: public
Privilege: http://tizen.org/privilege/notification
Parameters:
Exceptions:
with error type InvalidValuesError, if any of the input parameters contain an invalid value.
with error type SecurityError, if the application does not have the privilege to call this method or if the author signature does not match that of the designated application.
with error type UnknownError, if the method cannot be completed because of an unknown error.
Code example:
try { tizen.badge.setBadgeCount("AVbg1ZHu6l.BadgeSample", 3); } catch(e) { console.log("Error Exception, error name : " + e.name + ", error message : " + e.message); }
getBadgeCount
long getBadgeCount(ApplicationId appId);
Since: 2.3
Privilege level: public
Privilege: http://tizen.org/privilege/notification
Parameters:
Return value:
long Count of the badgeExceptions:
with error type InvalidValuesError, if any of the input parameters contain an invalid value.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if the method cannot be completed because of an unknown error.
Code example:
try { var count = tizen.badge.getBadgeCount("AVbg1ZHu6l.BadgeSample"); } catch(e) { console.log("Error Exception, error name : " + e.name + ", error message : " + e.message); }
addChangeListener
void addChangeListener(ApplicationId[] appIdList, BadgeChangeCallback successCallback);
Since: 2.3
Privilege level: public
Privilege: http://tizen.org/privilege/notification
Parameters:
Exceptions:
with error type TypeMismatchError, if any input parameter is not of the expected type for that parameter.
with error type InvalidValuesError, if any of the input parameters contains an invalid value.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
Code example:
function watcher(appId, count) { console.log(appId + ' badge number were updated : ' + count); } // Registers to be notified when the badge number changes tizen.badge.addChangeListener(["AVbg1ZHu6l.BadgeSample", "BDb5tZJe47.TestSample"], watcher);
removeChangeListener
void removeChangeListener(ApplicationId[] appIdList);
Since: 2.3
Privilege level: public
Privilege: http://tizen.org/privilege/notification
Parameters:
Exceptions:
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 UnknownError if any other error occurs.
Code example:
// Receives badge number changes function watcher(appId, count) { console.log(appId + ' badge number were updated : ' + count); } // Registers to be notified when the badge number changes tizen.badge.addChangeListener(["AVbg1ZHu6l.BadgeSample", "BDb5tZJe47.TestSample"], watcher); // Cancels the watch operation tizen.badge.removeChangeListener(["AVbg1ZHu6l.BadgeSample", "BDb5tZJe47.TestSample"]);
[Callback=FunctionOnly, NoInterfaceObject] interface BadgeChangeCallback { void onsuccess(ApplicationId appId, long count); };
Since: 2.3
onsuccess
void onsuccess(ApplicationId appId, long count);
Since: 2.3
Parameters:
module Badge{ [NoInterfaceObject] interface BadgeManagerObject { readonly attribute BadgeManager badge; }; Tizen implements BadgeManagerObject; [NoInterfaceObject] interface BadgeManager { readonly attribute long maxBadgeCount; void setBadgeCount(ApplicationId appId, long count) raises(WebAPIException); long getBadgeCount(ApplicationId appId) raises(WebAPIException); void addChangeListener(ApplicationId[]appIdList, BadgeChangeCallback successCallback) raises(WebAPIException); void removeChangeListener(ApplicationId[] appIdList) raises(WebAPIException); }; [Callback=FunctionOnly, NoInterfaceObject] interface BadgeChangeCallback { void onsuccess(ApplicationId appId, long count); }; };