?【關鍵詞】
權限、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}