Search code examples
iosappceleratorqr-codeappcelerator-titanium

Appcelerator app crashing on Barcode.capture() line on iOS device


I need to read QR code in my app. So I am testing on the iOS device. I added module and I am using this example so far

enter link description here

App crashing on this line

Barcode.capture({
       animate: true,
       overlay: overlay,
       showCancel: false,
       showRectangle: false,
       keepOpen: true/*,
       acceptedFormats: [
           Barcode.FORMAT_QR_CODE
       ]*/
   });

I tried also without params like this Barcode.capture(); but still crashing.

SDK version is 6.0.1.GA

ti.barcode version is 1.9.1


Solution

  • Most likely if there is no log showing the crash then it is related to NSCameraUsageDescription key-value in tiapp.xml.

    Add it like this:

    <ios>
        <enable-launch-screen-storyboard>false</enable-launch-screen-storyboard>
        <plist>
            <dict>
                <key>UISupportedInterfaceOrientations~iphone</key>
                <array>
                    <string>UIInterfaceOrientationPortrait</string>
                </array>
                <key>UISupportedInterfaceOrientations~ipad</key>
                <array>
                    <string>UIInterfaceOrientationPortrait</string>
                    <string>UIInterfaceOrientationPortraitUpsideDown</string>
                </array>
                <key>UIRequiresPersistentWiFi</key>
                <false/>
                <key>UIPrerenderedIcon</key>
                <false/>
                <key>UIStatusBarHidden</key>
                <false/>
                <key>UIStatusBarStyle</key>
                <string>UIStatusBarStyleLightContent</string>
    
                <key>NSCameraUsageDescription</key>
                <string>Can we use your camera?</string>
    
                <key>NSPhotoLibraryUsageDescription</key>
                <string>Can we save to your library?</string>
            </dict>
        </plist>
    </ios>