Audio recorder immediately dismissed after pressing the record button on device

Has anybody successfully got an audio recording on real device? I've tryed using presentAudioRecorderControllerWithOutputURL but only get a WatchKitRecordingFailedError, and the interface dismissed immediately. If I set WKAudioRecorderControllerOptionsAutorecordKey to NO then the record interface dismissed after I pressed the record button. Please HELP!

And here is my code:


NSURL *directory = [NSURL fileURLWithPath:NSTemporaryDirectory()];

NSURL * outputURL = [directory URLByAppendingPathComponent:@"temp.wav"];

[self presentAudioRecorderControllerWithOutputURL:outputURL preset:WKAudioRecorderPresetNarrowBandSpeech options:@{WKAudioRecorderControllerOptionsActionTitleKey:@"OK", WKAudioRecorderControllerOptionsMaximumDurationKey:@120, WKAudioRecorderControllerOptionsAutorecordKey:@0} completion:^(BOOL didSave, NSError * _Nullable error) {

//so I got didSave=0 and error=Error Domain=com.apple.watchkit.errors Code=6 "Recording failed." UserInfo={NSLocalizedDescription=Recording failed.}

}];


I've also tryed using a group directory instead by it didn't work either.


BTW, anybody can debug on real devices? I can never success on debuging on a real device, so I had to using NSURLSession to send the console log to my server and then be aware of what's going on...


Thanks a log!

You have to write the files to the shared group folder, as this is the only place both your app and extension can see.


    NSURL *container = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier: @"group.com.yourcompany.yourapp"];
    NSURL *fileUrl = [container URLByAppendingPathComponent:@"temp.wav"];

Thank you dorada, but I've already tried with this... But same issue still...

I have the same issue. I cannot get the recorder to stay up for more than a second or so. I will let you know if I figure anything out for how to work around this.

I am having the exact same issue and have tried using the local documents directory and the shared group directory. Has anyone found a possible cause for this behavior? It's driving me nuts.

I've got the same error code but I've fixed using wadxm's sugestion.


My working enviroments are like this,


xCode 7.0

watchKit 2.0

iOS 9.0

In case you've not figured it out...


The iOS app, the Watchkit Extension AND the WatchKit App bundle (the UI/"WatchKit.app") ALL have to be in the app group - the extension is inside the WatchKit app, which is inside the iOS App. For some reason the simulator doesn't catch this.


Make sure all three pieces have the same app group entitlement.

thanks ... this works for me

Audio recorder immediately dismissed after pressing the record button on device
 
 
Q