代码之家  ›  专栏  ›  技术社区  ›  user2875404

watchOS AudioRecorder没有输入,未请求许可

  •  0
  • user2875404  · 技术社区  · 6 年前

    我用这个代码来显示苹果手表上的录音机(取自 https://www.raywenderlich.com/345-audio-recording-in-watchos-tutorial )

    let outputURL = chatMasterController.newOutputURL()
        let preset = WKAudioRecorderPreset.narrowBandSpeech
        let options: [String : Any] =
            [WKAudioRecorderControllerOptionsMaximumDurationKey: 30]
    
    
        presentAudioRecorderController(
            withOutputURL: outputURL,
            preset: preset,
            options: options) {
                [weak self] (didSave: Bool, error: Error?) in
    
                guard didSave else { return }
                print("finished audio to \(chatID) at \(outputURL)")
    
                print(outputURL)
    
           }
    

    我尝试了另一个使用麦克风的应用程序,这个应用程序确实请求我允许录制音频。我以前担心已经取消了许可,所以我重新安装了我的应用程序,但没有改变任何东西-没有权限被要求,没有输入被生成。

    是否有遗漏的内容,例如导入库?

    1 回复  |  直到 6 年前
        1
  •  1
  •   user2875404    6 年前

    我现在明白了。你不仅仅需要 Privacy - Microphone Usage Description

    只把它放在手表上什么都不做,只把它放在iPhone上不让你直接把它放在手表上。所以你两个都需要。

    不知道为什么这一点没有记录在案,但它符合苹果的“我们正在走下坡路”运动:)