Search code examples
ionic-frameworkionic3ionic-native

Testing Ionic Native features with Ionic Dev app


I have installed ionic Dev app from the play store on my mobile. And I am able to access application directly on mobile just using:

ionic serve -c

But however, when I am trying to test ionic native feature for e.g Camera on my device, I am getting below error:

 Object(__WEBPACK_IMPORTED_MODULE_0__ionic_native_core__["cordova"]) is not a function. 
(In 'Object(__WEBPACK_IMPORTED_MODULE_0__ionic_native_core__["cordova"])(this, "getPicture", { "callbackOrder": "reverse" }, arguments)', 
'Object(__WEBPACK_IMPORTED_MODULE_0__ionic_native_core__["cordova"])' is an instance of Object)

Stack:

getPicture@http://192.168.100.4:8100/build/vendor.js:129897:138
scan@http://192.168.100.4:8100/build/main.js:44:88
callWithDebugContext@http://192.168.100.4:8100/build/vendor.js:15423:47
dispatchEvent@http://192.168.100.4:8100/build/vendor.js:10329:36
http://192.168.100.4:8100/build/vendor.js:39890:65
onInvokeTask@http://192.168.100.4:8100/build/vendor.js:5076:43
runTask@http://192.168.100.4:8100/build/polyfills.js:3:10844
invokeTask@http://192.168.100.4:8100/build/polyfills.js:3:16801
p@http://192.168.100.4:8100/build/polyfills.js:2:27654
v@http://192.168.100.4:8100/build/polyfills.js:2:27894

I have tried to search for this message, but there is not enough support. And I am also not able to figure out the meaning of the message.

Any suggestion on it?


Solution

  • I found the issue, I was testing on iPhone and we need to explicitly give settings to allow access to the camera in the config.xml file.

    I was able to do so, by adding below lines of code in config.xml file:

    <edit-config file="*-Info.plist" mode="merge" target="NSCameraUsageDescription">
        <string>Used to take pictures and Scan QR codes</string>
    </edit-config>
    

    I hope this will help others.