提交 70fcbee4 编写于 作者: J jidong

modify account demo code

Signed-off-by: Njidong <jidong4@huawei.com>
上级 9e77f76d
...@@ -899,7 +899,7 @@ getAllAccounts(owner: string, callback: AsyncCallback&lt;Array&lt;AppAccountInfo ...@@ -899,7 +899,7 @@ getAllAccounts(owner: string, callback: AsyncCallback&lt;Array&lt;AppAccountInfo
**示例:** **示例:**
```js ```js
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
const selfBundle = "com.example.actsgetallaaccounts"; const selfBundle = "com.example.actsgetallaaccounts";
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
console.debug("getAllAccounts err:" + JSON.stringify(err)); console.debug("getAllAccounts err:" + JSON.stringify(err));
...@@ -960,7 +960,7 @@ on(type: 'change', owners: Array&lt;string&gt;, callback: Callback&lt;Array&lt;A ...@@ -960,7 +960,7 @@ on(type: 'change', owners: Array&lt;string&gt;, callback: Callback&lt;Array&lt;A
**示例:** **示例:**
```js ```js
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
function changeOnCallback(data){ function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data)); console.debug("receive change data:" + JSON.stringify(data));
} }
...@@ -990,7 +990,7 @@ off(type: 'change', callback?: Callback<Array\<AppAccountInfo>>): void ...@@ -990,7 +990,7 @@ off(type: 'change', callback?: Callback<Array\<AppAccountInfo>>): void
**示例:** **示例:**
```js ```js
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
function changeOnCallback(data){ function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data)); console.debug("receive change data:" + JSON.stringify(data));
appAccountManager.off('change', function(){ appAccountManager.off('change', function(){
...@@ -1400,7 +1400,7 @@ getAllOAuthTokens(name: string, owner: string): Promise&lt;Array&lt;OAuthTokenIn ...@@ -1400,7 +1400,7 @@ getAllOAuthTokens(name: string, owner: string): Promise&lt;Array&lt;OAuthTokenIn
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => { appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => {
console.log('getAllOAuthTokens data: ' + JSON.stringify(data)); console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.log("getAllOAuthTokens err: " + JSON.stringify(err)); console.log("getAllOAuthTokens err: " + JSON.stringify(err));
}); });
...@@ -1495,7 +1495,7 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback&lt;Authentic ...@@ -1495,7 +1495,7 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback&lt;Authentic
[account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
[account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData", [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.OnResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}); });
}); });
``` ```
...@@ -1531,7 +1531,7 @@ getAuthenticatorCallback(sessionId: string): Promise&lt;AuthenticatorCallback&gt ...@@ -1531,7 +1531,7 @@ getAuthenticatorCallback(sessionId: string): Promise&lt;AuthenticatorCallback&gt
[account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
[account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData", [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.OnResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => { }).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
}); });
...@@ -1733,7 +1733,8 @@ checkAccountLabels(name: string, owner: string, labels: Array&lt;string&gt;, cal ...@@ -1733,7 +1733,8 @@ checkAccountLabels(name: string, owner: string, labels: Array&lt;string&gt;, cal
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", (err, data) => { var labels = ["student"];
appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", labels, (err, data) => {
console.log('checkAccountLabels: ' + JSON.stringify(data)); console.log('checkAccountLabels: ' + JSON.stringify(data));
console.log("checkAccountLabels err: " + JSON.stringify(err)); console.log("checkAccountLabels err: " + JSON.stringify(err));
}); });
...@@ -1765,7 +1766,8 @@ checkAccountLabels(name: string, owner: string, labels: Array&lt;string&gt;): Pr ...@@ -1765,7 +1766,8 @@ checkAccountLabels(name: string, owner: string, labels: Array&lt;string&gt;): Pr
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo").then((data) => { var labels = ["student"];
appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", labels).then((data) => {
console.log('checkAccountLabels: ' + JSON.stringify(data)); console.log('checkAccountLabels: ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.log("checkAccountLabels err: " + JSON.stringify(err)); console.log("checkAccountLabels err: " + JSON.stringify(err));
...@@ -2115,7 +2117,7 @@ onResult: (code: number, result: {[key: string]: any}) =&gt; void ...@@ -2115,7 +2117,7 @@ onResult: (code: number, result: {[key: string]: any}) =&gt; void
[account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
[account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData", [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.OnResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => { }).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
}); });
...@@ -2168,7 +2170,7 @@ onRequestContinued?: () =&gt; void ...@@ -2168,7 +2170,7 @@ onRequestContinued?: () =&gt; void
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234"; var sessionId = "1234";
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
callback.OnRequestContinued(); callback.onRequestContinued();
}).catch((err) => { }).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
}); });
...@@ -2295,7 +2297,7 @@ getRemoteObject(): rpc.RemoteObject; ...@@ -2295,7 +2297,7 @@ getRemoteObject(): rpc.RemoteObject;
callback.onResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
} }
verifyCredential(name: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback) { verifyCredential(name, options, callback) {
callback.onRequestRedirected({ callback.onRequestRedirected({
bundleName: "com.example.ohos.accountjsdemo", bundleName: "com.example.ohos.accountjsdemo",
abilityName: "com.example.ohos.accountjsdemo.VerifyAbility", abilityName: "com.example.ohos.accountjsdemo.VerifyAbility",
...@@ -2305,11 +2307,11 @@ getRemoteObject(): rpc.RemoteObject; ...@@ -2305,11 +2307,11 @@ getRemoteObject(): rpc.RemoteObject;
}); });
} }
setProperties(options: SetPropertiesOptions, callback: AuthenticatorCallback) { setProperties(options, callback) {
callback.onResult(account_appAccount.ResultCode.SUCCESS, {}); callback.onResult(account_appAccount.ResultCode.SUCCESS, {});
} }
checkAccountLabels(name: string, labels: Array<string>, callback: AuthenticatorCallback) { checkAccountLabels(name, labels, callback) {
var result = {[account_appAccount.Constants.KEY_BOOLEAN_RESULT]: false}; var result = {[account_appAccount.Constants.KEY_BOOLEAN_RESULT]: false};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册