Search code examples
cordovacordova-pluginsios10video-capturengcordova

$cordovaCapture.captureVideo Call Crashes Cordova App on iOS 10.1


I have a Cordova app (written for Android and iOS) that's been working fine in production with a fair number of users, including on iOS 10.0 after the necessary security tweaks a month or two ago. Now with the more recent 10.1 upgrades, (currently testing on 10.1.1) I find that attempts to call the video capture functionality completely crashes Cordova, without any option to debug from a JS-perspective. There is no issue on the Android side. This is just with the latest update to iOS, and there have been no code or plugin updates or changes.

We're using the most recent cordova-plugin-media-capture plugin, v1.4.0, with ngCordova. Calls to this plugin to take a photo via $cordovaCapture.captureImage work fine in iOS 10.1.1. It's just calls to $cordovaCapture.captureVideo which completely and instantly crash Cordova. I've looked at Xcode in case there are any new or out-of-whack settings and everything seems correct, so would welcome any suggestions on resolving this.

Earlier (a month or two ago) we resolved the new iOS 10 permissions issue using the cordova-plugin-settings-hook plug-in with these iOS settings (snippet shown) in config.xml:

<platform name="ios">
    <config-file parent="NSLocationWhenInUseUsageDescription" platform="ios" target="*-Info.plist">
        <string>Reason goes here...</string>
    </config-file>
    <config-file parent="NSCameraUsageDescription" platform="ios" target="*-Info.plist">
        <string>Reason goes here....</string>
    </config-file>
    <config-file parent="NSPhotoLibraryUsageDescription" platform="ios" target="*-Info.plist">
        <string>Reason goes here...</string>
    </config-file>

I confirmed these settings using Xcode. The parameters we pass in to the actual call are as follows:

$cordovaCapture.captureVideo
({
    limit:      1,  // how many clips to record (iOS must be 1)
    duration:   300 // maximum length (in seconds) = 5 minutes
})

Hoping someone else managed to resolve the same issue and is willing to share the workaround.


Solution

  • You are missing the NSMicrophoneUsageDescription, which is needed when you record a video.

    The strange thing is, 1.4.0 version of the plugin should add all the UsageDescriptions, you shouldn't need the cordova-plugin-settings-hook, but for some reason it is not working if you needed to add that plugin.

    On a clean new project with just the 1.4.0 media plugin it works as expected with no crash.