提交 7ea53b80 编写于 作者: zyjhandsome's avatar zyjhandsome

优化《向用户申请授权》示例代码

Signed-off-by: zyjhandsome's avatarzyjhandsome <zyjhandsome@126.com>
上级 02b2a7c9
......@@ -148,11 +148,14 @@
atManager.requestPermissionsFromUser(context, permissions).then((data) => {
console.info(`[requestPermissions] data: ${JSON.stringify(data)}`);
let grantStatus: Array<number> = data.authResults;
if (grantStatus[0] === -1) {
// 授权失败
} else {
// 授权成功
let length: number = grantStatus.length;
for (let i = 0; i < length; i++) {
if (grantStatus[i] !== 0) {
// 授权失败
return;
}
}
// 授权成功
}).catch((err) => {
console.error(`[requestPermissions] Failed to start request permissions. Error: ${JSON.stringify(err)}`);
})
......@@ -178,11 +181,14 @@
atManager.requestPermissionsFromUser(context, permissions).then((data) => {
console.info(`[requestPermissions] data: ${JSON.stringify(data)}`);
let grantStatus: Array<number> = data.authResults;
if (grantStatus[0] === -1) {
// 授权失败
} else {
// 授权成功
let length: number = grantStatus.length;
for (let i = 0; i < length; i++) {
if (grantStatus[i] !== 0) {
// 授权失败
return;
}
}
// 授权成功
}).catch((err) => {
console.error(`[requestPermissions] Failed to start request permissions. Error: ${JSON.stringify(err)}`);
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册