The basic concepts are:
To use add(), remove(), and update() methods of AccountManager can be invoked only
by account provider application. A web application is an account provider when its config.xml contains Account provider section. For example:
<tizen:account multiple-account-support="true">
<tizen:icon section="Account">icon.png</tizen:icon>
<tizen:icon section="AccountSmall">icon.png</tizen:icon>
<tizen:display-name xml:lang="en-gb">Test</tizen:display-name>
<tizen:capability>http://tizen.org/account/capability/contact</tizen:capability>
</tizen:account>
For more information about how to use Account API, see Account Guide.
Since: 2.3
[NoInterfaceObject] interface AccountManagerObject { readonly attribute AccountManager account; };
Tizen implements AccountManagerObject;
Since: 2.3
The tizen.account object allows accessing the functionality of the Account API. There is one account manager in one web runtime. The Accounts back-end may support multiple account managers.
[NoInterfaceObject] interface AccountProvider { readonly attribute ApplicationId applicationId; readonly attribute DOMString displayName; readonly attribute DOMString iconUri; readonly attribute DOMString smallIconUri; readonly attribute DOMString[] capabilities; readonly attribute boolean isMultipleAccountSupported; };
Since: 2.3
Since: 2.3
Since: 2.3
Since: 2.3
Since: 2.3
The following predefined capabilities can be used.
Since: 2.3
Since: 2.3
dictionary AccountInit { DOMString userName; DOMString iconUri; };
Since: 2.3
[Constructor(AccountProvider provider, optional AccountInit? accountInitDict)] interface Account { readonly attribute AccountId? id; attribute DOMString? userName; attribute DOMString? iconUri; readonly attribute AccountProvider provider; void setExtendedData(DOMString key, DOMString value) raises(WebAPIException); DOMString getExtendedData(DOMString key) raises(WebAPIException); void getExtendedData( AccountExtendedDataArraySuccessCallback successCallback, optional ErrorCallback? errorCallback ) raises(WebAPIException); };
Since: 2.3
The information is hidden from web applications.
Account(AccountProvider provider, optional AccountInit? accountInitDict);
Since: 2.3
Since: 2.3
Since: 2.3
Since: 2.3
setExtendedData
void setExtendedData(DOMString key, DOMString value);
Since: 2.3
If the specified key already exists, the corresponding value is overwritten with the specified value.
Privilege level: public
Privilege: http://tizen.org/privilege/account.write
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
var appId = tizen.application.getCurrentApplication().appInfo.id; tizen.account.getAccounts(function(accounts) { var account = accounts[0]; if(account) { var key = 'nickname'; var value = 'nickname of anonymous user'; account.setExtendedData(key, value); console.log(account.getExtendedData(key)); // 'nickname of anonymous user' account.setExtendedData(key, 'nickname updated'); console.log(account.getExtendedData(key)); // 'nickname updated' } }, function(e) { console.log('Error: ' + e.message); }, appId);
getExtendedData
DOMString getExtendedData(DOMString key);
Since: 2.3
Privilege level: public
Privilege: http://tizen.org/privilege/account.read
Parameters:
Return value:
value Value of the extended dataExceptions:
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:
var appId = tizen.application.getCurrentApplication().appInfo.id; tizen.account.getAccounts(function(accounts) { var account = accounts[0]; if(account) { var key = 'accessToken'; var value = account.getExtendedData(key); console.log(account.userName + "'s accessToken is " + value); } }, function(e) { console.log('Error: ' + e.message); }, appId);
getExtendedData
void getExtendedData(AccountExtendedDataArraySuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.3
Privilege level: public
Privilege: http://tizen.org/privilege/account.read
Parameters:
Exceptions:
with error type TypeMismatchError, if any of the 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:
var appId = tizen.application.getCurrentApplication().appInfo.id; tizen.account.getAccounts(function(accounts) { var account = accounts[0]; if(account) { account.getExtendedData(function(extendedData) { for(var i=0; i < extendedData.length; i++) { var key = extendedData.key; var value = extendedData.value; console.log(key + " : " + value); } }, function(e) { console.log("Error : " + e.message); }); } }, function(e) { console.log('Error: ' + e.message); }, appId);
[NoInterfaceObject] interface AccountManager { void add(Account account) raises(WebAPIException); void remove(AccountId accountId) raises(WebAPIException); void update(Account account) raises(WebAPIException); Account? getAccount(AccountId accountId) raises(WebAPIException); void getAccounts( AccountArraySuccessCallback successCallback, optional ErrorCallback? errorCallback, optional DOMString? applicationId) raises(WebAPIException); AccountProvider? getProvider(ApplicationId applicationId) raises(WebAPIException); void getProviders( AccountProviderArraySuccessCallback successCallback, optional ErrorCallback? errorCallback, optional DOMString? capability) raises(WebAPIException); long addAccountListener(AccountChangeCallback callback) raises(WebAPIException); void removeAccountListener(long accountListenerId) raises(WebAPIException); };
Since: 2.3
add
void add(Account account);
Since: 2.3
If the account is added successfully, an accountId and provider are newly assigned when the function returns.
This method can be used only by an account provider application.
If the application is registered as provider, it will be launched to authenticate the account.
You should implement the appcontrol for the account provider.
For more details, see
Account Provider
Privilege level: public
Privilege: http://tizen.org/privilege/account.write
Parameters:
Exceptions:
with error type TypeMismatchError, if any of the 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:
var appId = tizen.application.getCurrentApplication().appInfo.id; var provider = tizen.account.getProvider(appId); var account = new tizen.Account(provider, {userName: 'admin', iconUri: 'path/to/icon.jpg'}); tizen.account.add(account);
remove
void remove(AccountId accountId);
Since: 2.3
Removes the account in the database that corresponds to the specified identifier. The function will throw an exception if it failed to remove the specified account.
This method can be used by an account provider application.
Privilege level: public
Privilege: http://tizen.org/privilege/account.write
Parameters:
Exceptions:
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:
var appId = tizen.application.getCurrentApplication().appInfo.id; tizen.account.getAccounts(function(accounts) { var account = accounts[0]; if(account) { tizen.account.remove(account.id); } }, function(e) { console.log('Error: ' + e.message); }, appId);
update
void update(Account account);
Since: 2.3
This method can be used only an account provider application.
Privilege level: public
Privilege: http://tizen.org/privilege/account.write
Parameters:
Exceptions:
with error type TypeMismatchError, if any of the 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:
var appId = tizen.application.getCurrentApplication().appInfo.id; tizen.account.getAccounts(function(accounts) { var account = accounts[0]; if(account) { account.userName = 'abc'; tizen.account.update(account); }) }, function(e) { console.log('Error: ' + e.message); }, appId);
getAccount
Since: 2.3
Privilege level: public
Privilege: http://tizen.org/privilege/account.read
Parameters:
Return value:
Account object with the given identifier, or nullExceptions:
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:
var account = tizen.account.getAccount(1);
getAccounts
void getAccounts(AccountArraySuccessCallback successCallback, optional ErrorCallback? errorCallback, optional DOMString? applicationId);
Since: 2.3
Privilege level: public
Privilege: http://tizen.org/privilege/account.read
Parameters:
Exceptions:
with error type TypeMismatchError, if any of the 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:
tizen.account.getAccounts(function(accounts) { // accounts is an array whose members are all registered accounts in this device. }, function (e) { console.log("Error : " + e.message); });
getProvider
AccountProvider? getProvider(ApplicationId applicationId);
Since: 2.3
You can register your application as an account provider by writing account related information in config.xml.
For more details, see
Account Provider
Privilege level: public
Privilege: http://tizen.org/privilege/account.read
Parameters:
Return value:
Provider object with the given applicationId, or nullExceptions:
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:
var appId = tizen.application.getCurrentApplication().appInfo.id; var provider = tizen.account.getProvider(appId); if (!provider) { console.log('current application is not account provider.'); }
getProviders
void getProviders(AccountProviderArraySuccessCallback successCallback, optional ErrorCallback? errorCallback, optional DOMString? capability);
Since: 2.3
Privilege level: public
Privilege: http://tizen.org/privilege/account.read
Parameters:
Exceptions:
with error type TypeMismatchError, if any of the 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:
tizen.account.getProviders(function(providers) { // providers is an array whose members are account providers // which have contact capability. }, function (e) { console.log('Error : ' + e.message); }, "http://tizen.org/account/capability/contact");
addAccountListener
long addAccountListener(AccountChangeCallback callback);
Since: 2.3
Privilege level: public
Privilege: http://tizen.org/privilege/account.read
Parameters:
Return value:
long Identifier to clear the watch subscription for account changesExceptions:
with error type TypeMismatchError, if any of the 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:
tizen.account.addAccountListener({ onadded: function(account) { // a callback function which will be called when account is added. }, onremoved: function(accountId) { // a callback function which will be called when account is removed. }, onupdated: function(account) { // a callback function which will be called when account is updated. } });
removeAccountListener
void removeAccountListener(long accountListenerId);
Since: 2.3
Privilege level: public
Privilege: http://tizen.org/privilege/account.read
Parameters:
Exceptions:
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:
var watchId = tizen.account.addAccountListener({ onadded: function(account) { // a callback function which will be called when account is added. }, onremoved: function(accountId) { // a callback function which will be called when account is removed. }, onupdated: function(account) { // a callback function which will be called when account is updated. } }); tizen.account.removeAccountListener(watchId);
[NoInterfaceObject] interface AccountExtendedData { readonly attribute DOMString key; readonly attribute DOMString value; };
Since: 2.3
Since: 2.3
Since: 2.3
[Callback, NoInterfaceObject] interface AccountArraySuccessCallback { void onsuccess(Account[] accounts); };
Since: 2.3
onsuccess
void onsuccess(Account[] accounts);
Since: 2.3
Parameters:
[Callback, NoInterfaceObject] interface AccountExtendedDataArraySuccessCallback { void onsuccess(AccountExtendedData[] extendedDataArray); };
Since: 2.3
onsuccess
void onsuccess(AccountExtendedData[] extendedDataArray);
Since: 2.3
Parameters:
[Callback, NoInterfaceObject] interface AccountProviderArraySuccessCallback { void onsuccess(AccountProvider[] providers); };
Since: 2.3
onsuccess
void onsuccess(AccountProvider[] providers);
Since: 2.3
Parameters:
[Callback, NoInterfaceObject] interface AccountChangeCallback { void onadded(Account account); void onremoved(AccountId accountId); void onupdated(Account account); };
Since: 2.3
onadded
void onadded(Account account);
Since: 2.3
Parameters:
onremoved
void onremoved(AccountId accountId);
Since: 2.3
Parameters:
onupdated
void onupdated(Account account);
Since: 2.3
Parameters:
To guarantee that the account application runs on a device which supports Account API, declare the following feature requirements in the config file:
module Account { [NoInterfaceObject] interface AccountManagerObject { readonly attribute AccountManager account; }; Tizen implements AccountManagerObject; typedef unsigned long AccountId; [NoInterfaceObject] interface AccountProvider { readonly attribute ApplicationId applicationId; readonly attribute DOMString displayName; readonly attribute DOMString iconUri; readonly attribute DOMString smallIconUri; readonly attribute DOMString[] capabilities; readonly attribute boolean isMultipleAccountSupported; }; dictionary AccountInit { DOMString userName; DOMString iconUri; }; [Constructor(AccountProvider provider, optional AccountInit? accountInitDict)] interface Account { readonly attribute AccountId? id; attribute DOMString? userName; attribute DOMString? iconUri; readonly attribute AccountProvider provider; void setExtendedData(DOMString key, DOMString value) raises(WebAPIException); DOMString getExtendedData(DOMString key) raises(WebAPIException); void getExtendedData( AccountExtendedDataArraySuccessCallback successCallback, optional ErrorCallback? errorCallback ) raises(WebAPIException); }; [NoInterfaceObject] interface AccountManager { void add(Account account) raises(WebAPIException); void remove(AccountId accountId) raises(WebAPIException); void update(Account account) raises(WebAPIException); Account? getAccount(AccountId accountId) raises(WebAPIException); void getAccounts( AccountArraySuccessCallback successCallback, optional ErrorCallback? errorCallback, optional DOMString? applicationId) raises(WebAPIException); AccountProvider? getProvider(ApplicationId applicationId) raises(WebAPIException); void getProviders( AccountProviderArraySuccessCallback successCallback, optional ErrorCallback? errorCallback, optional DOMString? capability) raises(WebAPIException); long addAccountListener(AccountChangeCallback callback) raises(WebAPIException); void removeAccountListener(long accountListenerId) raises(WebAPIException); }; [NoInterfaceObject] interface AccountExtendedData { readonly attribute DOMString key; readonly attribute DOMString value; }; [Callback, NoInterfaceObject] interface AccountArraySuccessCallback { void onsuccess(Account[] accounts); }; [Callback, NoInterfaceObject] interface AccountExtendedDataArraySuccessCallback { void onsuccess(AccountExtendedData[] extendedDataArray); }; [Callback, NoInterfaceObject] interface AccountProviderArraySuccessCallback { void onsuccess(AccountProvider[] providers); }; [Callback, NoInterfaceObject] interface AccountChangeCallback { void onadded(Account account); void onremoved(AccountId accountId); void onupdated(Account account); }; };