Hi There,
I am using Ionic React v5 and I wanted to utilise the Barcode scanner in my app. I followed the instructions here Cordova Plugins | Cordova Community Core Plugins for Ionic Apps and used the source code as it. was written. I would expect it to work when I run it in the simulator using Capacitor npx cap run ios
. All I get from the logs is: To Native Cordova → BarcodeScanner scan BarcodeScanner1226179492 [“options”: []]
What am I missing? Here is my package.json. Thanks in advance.
“dependencies”: {
“@capacitor-community/barcode-scanner”: “^2.0.1”,
“@capacitor/core”: “3.1.2”,
“@capacitor/ios”: “^3.2.4”,
“@ionic-native/barcode-scanner”: “^5.36.0”,
“@ionic-native/core”: “^5.36.0”,
“@ionic/react”: “^5.6.13”,
“@ionic/react-router”: “^5.6.13”,
“@testing-library/jest-dom”: “^5.14.1”,
“@testing-library/react”: “^12.0.0”,
“@testing-library/user-event”: “^13.2.1”,
“@types/jest”: “^27.0.1”,
“@types/node”: “^16.6.1”,
“@types/react”: “^17.0.18”,
“@types/react-dom”: “^17.0.9”,
“@types/react-router”: “^5.1.16”,
“@types/react-router-dom”: “^5.1.8”,
“browser”: “^0.2.6”,
“ionicons”: “^5.5.3”,
“phonegap-plugin-barcodescanner”: “^8.1.0”,
“react”: “^17.0.2”,
“react-dom”: “^17.0.2”,
“react-router”: “^5.2.0”,
“react-router-dom”: “^5.2.0”,
“react-scripts”: “4.0.3”,
“rxjs”: “^7.3.1”,
“typescript”: “4.3.5”
},
import { BarcodeScanner } from "@ionic-native/barcode-scanner";
const Wallet: React.FC = () => {
const dataToScan = async () => {
console.log("dataToScan called");
const data = await BarcodeScanner.scan(); // start scanning and wait for a result
console.log(`Barcode data: ${data.text}`);
};