未验证 提交 df133fe4 编写于 作者: Q ql 提交者: Gitee

update zh-cn/application-dev/ability/fa-pageability.md.

Signed-off-by: Nql <qianli16@huawei.com>
上级 d163a220
...@@ -143,34 +143,34 @@ ability支持单实例和多实例两种启动模式。 ...@@ -143,34 +143,34 @@ ability支持单实例和多实例两种启动模式。
import abilityAccessCtrl from "@ohos.abilityAccessCtrl"; import abilityAccessCtrl from "@ohos.abilityAccessCtrl";
import bundle from '@ohos.bundle'; import bundle from '@ohos.bundle';
async function RequestPermission() { async function RequestPermission() {
console.info('RequestPermission begin'); console.info('RequestPermission begin');
let array: Array<string> = ["ohos.permission.DISTRIBUTED_DATASYNC"]; let array: Array<string> = ["ohos.permission.DISTRIBUTED_DATASYNC"];
let bundleFlag = 0; let bundleFlag = 0;
let tokenID = undefined; let tokenID = undefined;
let userID = 100; let userID = 100;
let appInfo = await bundle.getApplicationInfo('ohos.samples.etsDemo', bundleFlag, userID); let appInfo = await bundle.getApplicationInfo('ohos.samples.etsDemo', bundleFlag, userID);
tokenID = appInfo.accessTokenId; tokenID = appInfo.accessTokenId;
let atManager = abilityAccessCtrl.createAtManager(); let atManager = abilityAccessCtrl.createAtManager();
let requestPermissions: Array<string> = []; let requestPermissions: Array<string> = [];
for (let i = 0;i < array.length; i++) { for (let i = 0;i < array.length; i++) {
let result = await atManager.verifyAccessToken(tokenID, array[i]); let result = await atManager.verifyAccessToken(tokenID, array[i]);
console.info("verifyAccessToken result:" + JSON.stringify(result)); console.info("verifyAccessToken result:" + JSON.stringify(result));
if (result != abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) { if (result != abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
requestPermissions.push(array[i]); requestPermissions.push(array[i]);
}
} }
} console.info("requestPermissions:" + JSON.stringify(requestPermissions));
console.info("requestPermissions:" + JSON.stringify(requestPermissions)); if (requestPermissions.length == 0 || requestPermissions == []) {
if (requestPermissions.length == 0 || requestPermissions == []) { return;
return; }
} let context = featureAbility.getContext();
let context = featureAbility.getContext(); context.requestPermissionsFromUser(requestPermissions, 1, (data)=>{
context.requestPermissionsFromUser(requestPermissions, 1, (data)=>{ console.info("data:" + JSON.stringify(data));
console.info("data:" + JSON.stringify(data)); console.info("data requestCode:" + data.requestCode);
console.info("data requestCode:" + data.requestCode); console.info("data permissions:" + data.permissions);
console.info("data permissions:" + data.permissions); console.info("data authResults:" + data.authResults);
console.info("data authResults:" + data.authResults); });
}); console.info('RequestPermission end');
console.info('RequestPermission end');
} }
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册