【快应用】小程序转快应用中如何获取用户已授权的权限

 【关键词】

权限、SystemInfo、setting

【问题背景】

小程序转快应用,用户在使用快应用的过程中如果产生了一些授权行为,开发者是否有办法去收集到用户已经授权过的权限呢,从而进行更好管理呢?

【解决方案】

小程序转快应用中是可行的,方法有如下两种:

1、  通过qa.getSystemInfoSync()接口返回的信息。如下图所示:

代码:

  getset2() {

    const sysInfo = qa.getSystemInfoSync()

    console.log(sysInfo)

  }

运行结果:

 "devicePixelRatio":3,"albumAuthorized":false,"cameraAuthorized":false,"locationAuthorized":false,"microphoneAuthorized":false,"notificationAuthorized":false,"notificationAlertAuthorized":false,"notificationBadgeAuthorized":false,"notificationSoundAuthorized":false,"bluetoothEnabled":false,"locationEnabled":true,"wifiEnabled":true,

2、  通过qa.getSetting获取当前用户的设置。

代码:

     qa.getSetting({

      success(res) {

        console.log("getSetting success, authSetting = " + JSON.stringify(res.authSetting))

      }

    })

运行结果:

 getSetting success, authSetting = {"scope.userLocation":false,"scope.writePhotosAlbum":true,"scope.record":false,"scope.camera":false,"scope.userInfo":false,"scope.address":false,"scope.invoiceTitle":false,"scope.invoice":false,"scope.werun":false}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值