0

I wanted to record my Audio on Applewatch and send to my iPhone. I created a URL to store the file and everytime I try this on my simulator it is working fine but on real device nothing happes with this error

Error: Error Domain=com.apple.watchkit.errors Code=3 “(null)”

URL:

var dir = fileManager.containerURL(forSecurityApplicationGroupIdentifier: "group.com.companyname.projektname")

RECORD:

presentAudioRecorderController(withOutputURL: dir,preset:.narrowBandSpeech,
                                                            options: nil,
                                                            completion:.........
989
  • 12,579
  • 5
  • 31
  • 53
Osman
  • 1,496
  • 18
  • 22

2 Answers2

1

On WatchOS 3 you also need to add a "Privacy - Microphone Usage Description" entry in the info.plist file of your iOS app (not the WatchKit app). Then on the iPhone you must agree with using the microphone.

I found this here: https://forums.developer.apple.com/thread/62612

Pierre America
  • 146
  • 1
  • 4
0

Please try below code:

Define URL :

var saveUrl: NSURL?

let container = 
    fileManager.containerURLForSecurityApplicationGroupIdentifier(
        "group.com.companyname.projektname")

let fileName = "audioFile.wav"

saveUrl = container?.URLByAppendingPathComponent(fileName)

Recording Code :

let duration = NSTimeInterval(10)

let recordOptions = 
         [WKAudioRecorderControllerOptionsMaximumDurationKey : duration]

presentAudioRecorderControllerWithOutputURL(saveUrl!, 
         preset: .NarrowBandSpeech,
         options: recordOptions, 
         completion: { saved, error in

            if let err = error {
                print(err.description)
            }

            if saved {
                self.playButton.setEnabled(true)
            }
      })

Hope this will help you...

Ketan P
  • 4,259
  • 3
  • 30
  • 36