wx.getLocation获取用户操作
发布于 5 年前 作者 jie66 1607 次浏览 来自 问答

在调用接口的时候,如何获取用户是允许还是拒绝授权

1 回复
// 可以通过 wx.getSetting 先查询一下用户是否授权了 "scope.record" 这个 scopewx.getSetting({
  success(res) {    if (!res.authSetting['scope.record']) {
      wx.authorize({        scope: 'scope.record',
        success() {          // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问
          wx.startRecord()
        }
      })
    }
  }
}
回到顶部