收藏
回答

wx.authorize调取录音权限真机上会弹出两次弹窗

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.authorize 微信iOS客户端 8.0.54 3.7.0

  wx.getSetting({

        success: (res) => {

        if(!res.authSetting['scope.record']){

        //开始录音

        wx.authorize({

            scope: 'scope.record',

            success() {

              console.log("录音授权成功");

              //第一次成功授权后 状态切换为2

            },

            fail() {

              console.log("第一次录音授权失败");

              wx.showModal({

                title: '提示',

                content: '您未授权录音,功能将无法使用',

                showCancel: true,

                confirmText: "授权",

                confirmColor: "#52a2d8",

                success: function (res) {

                  if (res.confirm{

                    //确认则打开设置页面(重点)

                    wx.openSetting({

                      success: (res) => {

                        if (!res.authSetting['scope.record']) {

                          //未设置录音授权

                          console.log("未设置录音授权");

                          wx.showModal({

                            title: '提示',

                            content: '您未授权录音,功能将无法使用',

                            showCancel: false,

                            success: function (res) {

      

                            },

                          })

                        } else {

                          //第二次才成功授权

                          console.log("设置录音授权成功");

                        }

                      },

                      fail: function () {

                        console.log("授权设置录音失败");

                      }

                    })

                  } else if (res.cancel{

                    console.log("cancel");

                  }

                },

              })

            }

          })

        } else {

            console.log('已经授权')

          }

        }})


回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容