{"id":25932717,"url":"https://github.com/socketmobile/capturebasic-cordova-ios","last_synced_at":"2026-05-11T00:47:03.800Z","repository":{"id":115907389,"uuid":"186804892","full_name":"SocketMobile/capturebasic-cordova-ios","owner":"SocketMobile","description":"Very basic Cordova plugin working with Capture","archived":false,"fork":false,"pushed_at":"2024-05-08T17:52:27.000Z","size":465,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2026-04-21T05:32:01.514Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SocketMobile.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-05-15T10:34:35.000Z","updated_at":"2023-01-25T05:01:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"c9458c9a-58b3-4826-b21b-2dd5bc3f66ed","html_url":"https://github.com/SocketMobile/capturebasic-cordova-ios","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/SocketMobile/capturebasic-cordova-ios","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SocketMobile%2Fcapturebasic-cordova-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SocketMobile%2Fcapturebasic-cordova-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SocketMobile%2Fcapturebasic-cordova-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SocketMobile%2Fcapturebasic-cordova-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SocketMobile","download_url":"https://codeload.github.com/SocketMobile/capturebasic-cordova-ios/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SocketMobile%2Fcapturebasic-cordova-ios/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32877246,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-10T13:40:02.631Z","status":"ssl_error","status_checked_at":"2026-05-10T13:40:02.145Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-04T00:38:54.435Z","updated_at":"2026-05-11T00:47:03.792Z","avatar_url":"https://github.com/SocketMobile.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Socket Mobile Capture Basic iOS Cordova Plugin\n\n## Introduction\n\nThis Socket Mobile Capture Basic iOS Cordova plugin allows to use Socket Mobile barcode scanners with a Cordova application.\n\nThis Cordova plugin supports only iOS at this time.\n\n**NOTE** This code is subject to change. This should be considered as beta.\n\n**NOTE** This version requires a clone of this project and a clone of CaptureSDK Cocoapods.\nMake sure to watch this repository to be notified when new updates are made available.\n\n**NOTE** Most of Socket Mobile products are using Bluetooth Classic, but the NFC products (D600) and counter top products (S550, S370) are using BluetoothLE (Low Energy). Check the BluetoothLE paragraph for more information.\n\n## Installation\n\nClone this repository:\n`git clone git@github.com:SocketMobile/capturebasic-cordova-ios.git`\n\nUpdate the Capture Basic Cordova plugin with the Capture SDK files:\n\n```sh\n$\u003e cd capturebasic-cordova-ios\n$\u003e ./updateCaptureSdk.sh\n```\n\nOnce the Capture Basic Cordova plugin has been updated with the CaptureSDK files then the plugin is now ready to be added to your Cordova application:\n\n```sh\n$\u003e cordova plugin add /Users/me/documents/dev/github/capturebasic-cordova-ios\n```\n\nTo remove the plugin from your Cordova application:\n\n```sh\n$\u003e cordova plugin remove com-socketmobile-capturebasic-cordova\n```\n\n**IMPORTANT**\nMake sure the CaptureSDK.xcframework is embedded and signed in the General settings of your project.\n\n![General settings](assets/xcode-general.png)\n\n\n## Prequisites settings for the application\n\nSince the CaptureSDK is using Bluetooth make sure the following items are in your info.plist of your application:\n\nSupported External Protocol String should have an entry set to `com.socketmobile.chs`.\n\nThe Bluetooth Always Usage Description string should be set to describe to the end-user why we need the Bluetooth permission.\n\n![Info.plist](assets/xcode-info-plist.png)\n\n## Using the SDK in a Cordova application\n\nThis current version of the Capture SDK for Cordova is limited to notifications coming from the Socket Mobile barcode scanner.\n\nIf the code of your application is written using Typescript, you may want to declare the main object of the Capture Basic SDK as shown here:\n\n```sh\ndeclare let CaptureBasic: any;\n```\n\nThe first thing is to set the callback function that will receive the Capture SDK events:\n\n```sh\nCaptureBasic.addListener('notifications', (success)=\u003e{}, (error)=\u003e{});\n```\n\nThe success function should be modified to handle the various events coming from Capture such as `deviceArrival` when a scanner connects, `deviceRemoval` when the scanner disconnects and `decodedData` when the scanner reads a barcode.\n\n------------------\n\n**NOTE** This `CaptureBase.addListener()` should be invoked once the device is ready.\n\n```javascript\n// Wait for the deviceready event before using any of Cordova's device APIs.\n// See https://cordova.apache.org/docs/en/latest/cordova/events/events.html#deviceready\ndocument.addEventListener('deviceready', onDeviceReady, false);\n\n```\n\n------------------\n\nOnce the listener is setup then you need to register your application to Socket Mobile developer portal, by giving the app Bundle ID, your Socket Mobile developer ID and you'll retrieved a appKey.\n\nThe application is now ready to use Capture by calling this method:\n\n```javascript\nconst appInfo = {\n  appId: 'ios:com.socketmobile.tribeca',\n  developerId: 'bb57d8e1-f911-47ba-b510-693be162686a',\n  appKey: 'MC0CFGtbOAKfL/vF7EAXHDhg3SM6CUj5AhUArb8NDQPgMZ4V4uHHvLcla0lq5jI='\n};\n\nCaptureBasic.useCaptureBasic(appInfo,(success)=\u003e{\n      console.log('useCaptureBasic returns: ', success);\n    },(error)=\u003e{\n      console.log('useCaptureBasic returns an error: ', error);\n    });\n```\n\nAdding the listener could look like this:\n\n```javascript\nCaptureBasic.addListener('notifications', (success)=\u003e{\n  const notification = JSON.parse(success);\n  if (notification.name === 'initializeComplete') {\n    console.log('Capture initialization completed');\n  }\n  else if (notification.name === 'deviceArrival'){\n    console.log('device arrival: ', notification.deviceName);\n  }\n  else if (notification.name === 'deviceRemoval'){\n    console.log('no device connected');\n  }\n  else if (notification.name === 'decodedData') {\n    const decodedData = notification.decodedData.map(c =\u003e String.fromCharCode(c)).join('');\n    console.log('decodedData: ', decodedData);\n  }\n},(error)=\u003e{\n  console.log('notification error: ', error);\n});\n```\n\n## Get/Set property\n\nIt is possible to get information from a connected scanner or to change the value of a device property by using the Set/Get property API.\n\nThe typical result when the get or set property returns is something similar to this:\n\n```javascript\n{\n  \"propId\" : 65803,\n  \"propType\" : 3,\n  \"value\" : 1677744640,\n  \"handle\" : \"10742802912\"\n}\n```\n\n### Example: Get Device Battery Level\n\nHere is an example of getting the battery level of a connected device:\n\n```javascript\nfunction getBatteryLevel() {\n    console.log('click on getBatteryLevel');\n    const property = {\n        handle: deviceHandle, // device from which we want battery level\n        propId: 65803, // battery level\n        propType: 0, // None\n    };\n    CaptureBasic.getProperty(property, success =\u003e {\n        console.log('getProperty success: ', success);\n        // the value is actually organized like this:\n        // MSB                        LSB\n        // ------------------------------\n        // |  0   | Max | Current | Min |\n        // ------------------------------  \n        const response = JSON.parse(success);\n        const percent = (parseInt(response.value, 10) \u0026 0xffff) \u003e\u003e 8;\n        console.log(`Battery is at ${percent}%`);\n    }, error =\u003e {\n        console.log('getProperty error: ', error);\n    })\n}\n```\n\n## Possible events received from Capture\n\n### Device Arrival\n\nEach time a scanner is connected and ready to be used then the device arrival event is generated to let the application know a new scanner is ready.\n\nThis event contains the information about the scanner such as its type and the friendly name associated to the scanner.\nThe device handle identifies the scanner in a unique fashion and changes each time the scanner connects.\n\nHere is the json data received in the Capture callback:\n\n```javascript\n{\n  \"deviceHandle\": \"10787750208\",\n  \"deviceType\": 196619,\n  \"name\": \"deviceArrival\",\n  \"type\": \"deviceType\",\n  \"deviceName\": \"Socket D740 [E537BA]\"\n}\n```\n\n### Device Removal\n\nThe device removal event occurs each time the scanner disconnects from the host.\nIt holds the information about the scanner that has just disconnected.\n\n```javascript\n{\n  \"deviceType\": 196619,\n  \"deviceHandle\": \"10787750208\",\n  \"name\": \"deviceRemoval\",\n  \"type\": \"deviceType\",\n  \"deviceName\": \"Socket D740 [E537BA]\"\n}\n```\n\n### Decoded Data\n\nEach time the scanner successfully scans a barcode, the decoded data event is generated holding the decoded data, the symbology ID and the symbology name as well as the scanner information from which the decoded data came from.\n\n```javascript\n{\n  \"deviceHandle\": \"10787750208\",\n  \"decodedData\": [\n    65,\n    55,\n    51,\n    54,\n    55,\n    79,\n    48,\n    51,\n    79,\n    68\n  ],\n  \"deviceName\": \"Socket D740 [E537BA]\",\n  \"deviceType\": 196619,\n  \"dataSourceId\": 11,\n  \"dataSourceName\": \"Code 39\",\n  \"type\": \"decodedData\",\n  \"name\": \"decodedData\"\n}\n```\n\nIf the type of the decoded data is UTF8 based a simple conversion can reformat the decoded data as a string like this:\n\n```javascript\nif (event.name === 'decodedData') {\n  const decodedData = event.decodedData.map(c =\u003e String.fromCharCode(c)).join('');\n  console.log('decodedData: ', decodedData);\n}\n```\n\n### Capture initialize Complete\n\nWhen Capture is initialized for the first time, an event is generated to confirm the result of the initialization.\n\n```javascript\n{\n  \"name\": \"initializeComplete\",\n  \"type\": \"result\",\n  \"result\": 0\n}\n```\n\n### Capture Terminated\n\nWhen ScanAPI is shutting down, a terminate event is sent to indicate to the application that it won't receive anymore notifications from Capture.\n\n```javascript\n{\n  \"name\" : \"captureBasicTerminated\"\n  \"type\": \"result\",\n  \"result\": 0\n}\n```\n\n### Error\n\nIf an error occurs, Capture will send an event that includes the error code.\n\n```javascript\n{\n  \"type\" : \"error\",\n  \"name\" : \"onError\",\n  \"result\" : -27\n}\n```\n\n## BluetoothLE products, mostly NFC Reader/Writer (D600, S550, S370)\n\nThe BluetoothLE uses a Bluetooth Manager with a concept of Favorite.\n\nIf the Favorite is set to an empty string (default), CaptureSDK won't discover any BluetoothLE devices. If it will discover only Bluetooth Classic devices.\n\nIf the Favorite is set with one \\* (wildchar) then it will discover and connect to ONE BluetoothLE Socket product. If the Favorite is set with 2 \\* (wildchar) it will discover and connect to 2 BluetoothLE Socket products.\n\nHere is an example of setting the Bluetooth Manager favorite\n\n```javascript\nfunction onDeviceReady() {\n    // Cordova is now initialized. Have fun!\n    CaptureBasic.addListener('notifications', (success)=\u003e{\n        console.log('Capture received: ', success);\n        const result = JSON.parse(success);\n        if(result.name === 'deviceArrival'){\n            console.log('got a device arrival, ask for battery level');\n            .../...\n        }\n        else if(result.name === 'deviceManagerArrival'){\n            console.log('got a device manager arrival, set the favorite to discover BLE devices');\n            deviceHandle = result.deviceHandle;\n            const property = {\n                handle: deviceHandle,\n                propId: 328193, // Favorite\n                propType: 5, // argument string\n                value: '*' // any Socket Mobile BLE\n            };\n            CaptureBasic.setProperty(property, success =\u003e {\n                console.log('setProperty success: ', success);\n            }, error =\u003e {\n                console.log('setProperty error: ', error);\n            })\n        }\n```\n\nOnce the Device Manager favorite is set, the BluetoothLE Socket Mobile product will connects as soon as it is turned on. The Capture Basic will send a notification if the device connects or disconnects like any other Socket Mobile products.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocketmobile%2Fcapturebasic-cordova-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsocketmobile%2Fcapturebasic-cordova-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocketmobile%2Fcapturebasic-cordova-ios/lists"}