├── .babelrc ├── .buckconfig ├── .eslintrc.js ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .prettierrc.js ├── .watchmanconfig ├── App.js ├── LICENSE ├── README.md ├── __tests__ └── App-test.js ├── android ├── .project ├── .settings │ └── org.eclipse.buildship.core.prefs ├── app │ ├── .classpath │ ├── .project │ ├── .settings │ │ └── org.eclipse.buildship.core.prefs │ ├── BUCK │ ├── build.gradle │ ├── build_defs.bzl │ ├── proguard-rules.pro │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── assets │ │ └── fonts │ │ │ ├── Entypo.ttf │ │ │ ├── EvilIcons.ttf │ │ │ ├── Feather.ttf │ │ │ ├── FontAwesome.ttf │ │ │ ├── FontAwesome5_Brands.ttf │ │ │ ├── FontAwesome5_Regular.ttf │ │ │ ├── FontAwesome5_Solid.ttf │ │ │ ├── Foundation.ttf │ │ │ ├── Ionicons.ttf │ │ │ ├── MaterialCommunityIcons.ttf │ │ │ ├── MaterialIcons.ttf │ │ │ ├── Octicons.ttf │ │ │ ├── SimpleLineIcons.ttf │ │ │ └── Zocial.ttf │ │ ├── java │ │ └── com │ │ │ └── datawedgereactnative │ │ │ └── demo │ │ │ ├── MainActivity.java │ │ │ └── MainApplication.java │ │ └── res │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── strings.xml │ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── keystores │ ├── BUCK │ └── debug.keystore.properties └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── metro.config.js ├── package-lock.json ├── package.json ├── screenshots ├── 6.3.png ├── 6.3_message.png ├── 6.4.png ├── application_01.png ├── application_02.png ├── datawedge_01.png ├── datawedge_02.png ├── datawedge_associated_apps.png ├── pre_6.3.png └── pre_6.3_message.png └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["module:metro-react-native-babel-preset"] 3 | } 4 | -------------------------------------------------------------------------------- /.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | }; 5 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | node_modules/react-native/Libraries/react-native/React.js 15 | 16 | ; Ignore polyfills 17 | node_modules/react-native/Libraries/polyfills/.* 18 | 19 | ; These should not be required directly 20 | ; require from fbjs/lib instead: require('fbjs/lib/warning') 21 | node_modules/warning/.* 22 | 23 | ; Flow doesn't support platforms 24 | .*/Libraries/Utilities/HMRLoadingView.js 25 | 26 | [untyped] 27 | .*/node_modules/@react-native-community/cli/.*/.* 28 | 29 | [include] 30 | 31 | [libs] 32 | node_modules/react-native/Libraries/react-native/react-native-interface.js 33 | node_modules/react-native/flow/ 34 | 35 | [options] 36 | emoji=true 37 | 38 | esproposal.optional_chaining=enable 39 | esproposal.nullish_coalescing=enable 40 | 41 | module.file_ext=.js 42 | module.file_ext=.json 43 | module.file_ext=.ios.js 44 | 45 | module.system=haste 46 | module.system.haste.use_name_reducers=true 47 | # get basename 48 | module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1' 49 | # strip .js or .js.flow suffix 50 | module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1' 51 | # strip .ios suffix 52 | module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1' 53 | module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1' 54 | module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1' 55 | module.system.haste.paths.blacklist=.*/__tests__/.* 56 | module.system.haste.paths.blacklist=.*/__mocks__/.* 57 | module.system.haste.paths.whitelist=/node_modules/react-native/Libraries/.* 58 | module.system.haste.paths.whitelist=/node_modules/react-native/RNTester/.* 59 | module.system.haste.paths.whitelist=/node_modules/react-native/IntegrationTests/.* 60 | module.system.haste.paths.blacklist=/node_modules/react-native/Libraries/react-native/react-native-implementation.js 61 | module.system.haste.paths.blacklist=/node_modules/react-native/Libraries/Animated/src/polyfills/.* 62 | 63 | munge_underscores=true 64 | 65 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 66 | 67 | suppress_type=$FlowIssue 68 | suppress_type=$FlowFixMe 69 | suppress_type=$FlowFixMeProps 70 | suppress_type=$FlowFixMeState 71 | 72 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\) 73 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+ 74 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 75 | 76 | [lints] 77 | sketchy-null-number=warn 78 | sketchy-null-mixed=warn 79 | sketchy-number=warn 80 | untyped-type-import=warn 81 | nonstrict-import=warn 82 | deprecated-type=warn 83 | unsafe-getters-setters=warn 84 | inexact-spread=warn 85 | unnecessary-invariant=warn 86 | signature-verification-failure=warn 87 | deprecated-utility=error 88 | 89 | [strict] 90 | deprecated-type 91 | nonstrict-import 92 | sketchy-null 93 | unclear-type 94 | unsafe-getters-setters 95 | untyped-import 96 | untyped-type-import 97 | 98 | [version] 99 | ^0.98.0 100 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # CocoaPods 59 | /ios/Pods/ 60 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: false, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | }; 7 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /App.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | * @flow 7 | */ 8 | 9 | import React, {Component} from 'react'; 10 | import {Platform, StyleSheet, Text, View, ScrollView, FlatList, TouchableHighlight, Alert} from 'react-native'; 11 | import {CheckBox, Button} from 'react-native-elements' 12 | import { DeviceEventEmitter } from 'react-native'; 13 | import DataWedgeIntents from 'react-native-datawedge-intents'; 14 | 15 | type Props = {}; 16 | export default class App extends Component { 17 | constructor(Props) 18 | { 19 | super(Props) 20 | this.state = { 21 | ean8checked: true, 22 | ean13checked: true, 23 | code39checked: true, 24 | code128checked: true, 25 | lastApiVisible: false, 26 | lastApiText: "Messages from DataWedge will go here", 27 | checkBoxesDisabled: true, 28 | scanButtonVisible: false, 29 | dwVersionText: "Pre 6.3. Please create and configure profile manually. See the ReadMe for more details", 30 | dwVersionTextStyle: styles.itemTextAttention, 31 | activeProfileText: "Requires DataWedge 6.3+", 32 | enumeratedScannersText: "Requires DataWedge 6.3+", 33 | scans: [], 34 | }; 35 | //this.scans = [{decoder: 'label', timeAtDecode: 'time', data: '123'}, 36 | // {decoder: 'label', timeAtDecode: 'time', data: '321'}, 37 | // {decoder: 'label', timeAtDecode: 'time', data: '123'}]; 38 | this.sendCommandResult = "false"; 39 | } 40 | 41 | componentDidMount() 42 | { 43 | this.state.deviceEmitterSubscription = DeviceEventEmitter.addListener('datawedge_broadcast_intent', (intent) => {this.broadcastReceiver(intent)}); 44 | this.registerBroadcastReceiver(); 45 | this.determineVersion(); 46 | } 47 | 48 | componentWillUnmount() 49 | { 50 | this.state.deviceEmitterSubscription.remove(); 51 | } 52 | 53 | _onPressScanButton() 54 | { 55 | this.sendCommand("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", 'TOGGLE_SCANNING'); 56 | } 57 | 58 | determineVersion() 59 | { 60 | this.sendCommand("com.symbol.datawedge.api.GET_VERSION_INFO", ""); 61 | } 62 | 63 | setDecoders() 64 | { 65 | // Set the new configuration 66 | var profileConfig = { 67 | "PROFILE_NAME": "ZebraReactNativeDemo", 68 | "PROFILE_ENABLED": "true", 69 | "CONFIG_MODE": "UPDATE", 70 | "PLUGIN_CONFIG": { 71 | "PLUGIN_NAME": "BARCODE", 72 | "PARAM_LIST": { 73 | //"current-device-id": this.selectedScannerId, 74 | "scanner_selection": "auto", 75 | "decoder_ean8": "" + this.state.ean8checked, 76 | "decoder_ean13": "" + this.state.ean13checked, 77 | "decoder_code128": "" + this.state.code128checked, 78 | "decoder_code39": "" + this.state.code39checked 79 | } 80 | } 81 | }; 82 | this.sendCommand("com.symbol.datawedge.api.SET_CONFIG", profileConfig); 83 | } 84 | 85 | sendCommand(extraName, extraValue) { 86 | console.log("Sending Command: " + extraName + ", " + JSON.stringify(extraValue)); 87 | var broadcastExtras = {}; 88 | broadcastExtras[extraName] = extraValue; 89 | broadcastExtras["SEND_RESULT"] = this.sendCommandResult; 90 | DataWedgeIntents.sendBroadcastWithExtras({ 91 | action: "com.symbol.datawedge.api.ACTION", 92 | extras: broadcastExtras}); 93 | } 94 | 95 | registerBroadcastReceiver() 96 | { 97 | DataWedgeIntents.registerBroadcastReceiver({ 98 | filterActions: [ 99 | 'com.zebra.reactnativedemo.ACTION', 100 | 'com.symbol.datawedge.api.RESULT_ACTION' 101 | ], 102 | filterCategories: [ 103 | 'android.intent.category.DEFAULT' 104 | ] 105 | }); 106 | } 107 | 108 | broadcastReceiver(intent) 109 | { 110 | // Broadcast received 111 | console.log('Received Intent: ' + JSON.stringify(intent)); 112 | if (intent.hasOwnProperty('RESULT_INFO')) { 113 | var commandResult = intent.RESULT + " (" + 114 | intent.COMMAND.substring(intent.COMMAND.lastIndexOf('.') + 1, intent.COMMAND.length) + ")";// + JSON.stringify(intent.RESULT_INFO); 115 | this.commandReceived(commandResult.toLowerCase()); 116 | } 117 | 118 | if (intent.hasOwnProperty('com.symbol.datawedge.api.RESULT_GET_VERSION_INFO')) { 119 | // The version has been returned (DW 6.3 or higher). Includes the DW version along with other subsystem versions e.g MX 120 | var versionInfo = intent['com.symbol.datawedge.api.RESULT_GET_VERSION_INFO']; 121 | console.log('Version Info: ' + JSON.stringify(versionInfo)); 122 | var datawedgeVersion = versionInfo['DATAWEDGE']; 123 | console.log("Datawedge version: " + datawedgeVersion); 124 | 125 | // Fire events sequentially so the application can gracefully degrade the functionality available on earlier DW versions 126 | if (datawedgeVersion >= "06.3") 127 | this.datawedge63(); 128 | if (datawedgeVersion >= "06.4") 129 | this.datawedge64(); 130 | if (datawedgeVersion >= "06.5") 131 | this.datawedge65(); 132 | 133 | this.setState(this.state); 134 | } 135 | else if (intent.hasOwnProperty('com.symbol.datawedge.api.RESULT_ENUMERATE_SCANNERS')) { 136 | // Return from our request to enumerate the available scanners 137 | var enumeratedScannersObj = intent['com.symbol.datawedge.api.RESULT_ENUMERATE_SCANNERS']; 138 | this.enumerateScanners(enumeratedScannersObj); 139 | } 140 | else if (intent.hasOwnProperty('com.symbol.datawedge.api.RESULT_GET_ACTIVE_PROFILE')) { 141 | // Return from our request to obtain the active profile 142 | var activeProfileObj = intent['com.symbol.datawedge.api.RESULT_GET_ACTIVE_PROFILE']; 143 | this.activeProfile(activeProfileObj); 144 | } 145 | else if (!intent.hasOwnProperty('RESULT_INFO')) { 146 | // A barcode has been scanned 147 | this.barcodeScanned(intent, new Date().toLocaleString()); 148 | } 149 | } 150 | 151 | datawedge63() 152 | { 153 | console.log("Datawedge 6.3 APIs are available"); 154 | // Create a profile for our application 155 | this.sendCommand("com.symbol.datawedge.api.CREATE_PROFILE", "ZebraReactNativeDemo"); 156 | 157 | this.state.dwVersionText = "6.3. Please configure profile manually. See ReadMe for more details."; 158 | 159 | // Although we created the profile we can only configure it with DW 6.4. 160 | this.sendCommand("com.symbol.datawedge.api.GET_ACTIVE_PROFILE", ""); 161 | 162 | // Enumerate the available scanners on the device 163 | this.sendCommand("com.symbol.datawedge.api.ENUMERATE_SCANNERS", ""); 164 | 165 | // Functionality of the scan button is available 166 | this.state.scanButtonVisible = true; 167 | 168 | } 169 | 170 | datawedge64() 171 | { 172 | console.log("Datawedge 6.4 APIs are available"); 173 | 174 | // Documentation states the ability to set a profile config is only available from DW 6.4. 175 | // For our purposes, this includes setting the decoders and configuring the associated app / output params of the profile. 176 | this.state.dwVersionText = "6.4."; 177 | this.state.dwVersionTextStyle = styles.itemText; 178 | //document.getElementById('info_datawedgeVersion').classList.remove("attention"); 179 | 180 | // Decoders are now available 181 | this.state.checkBoxesDisabled = false; 182 | 183 | // Configure the created profile (associated app and keyboard plugin) 184 | var profileConfig = { 185 | "PROFILE_NAME": "ZebraReactNativeDemo", 186 | "PROFILE_ENABLED": "true", 187 | "CONFIG_MODE": "UPDATE", 188 | "PLUGIN_CONFIG": { 189 | "PLUGIN_NAME": "BARCODE", 190 | "RESET_CONFIG": "true", 191 | "PARAM_LIST": {} 192 | }, 193 | "APP_LIST": [{ 194 | "PACKAGE_NAME": "com.datawedgereactnative.demo", 195 | "ACTIVITY_LIST": ["*"] 196 | }] 197 | }; 198 | this.sendCommand("com.symbol.datawedge.api.SET_CONFIG", profileConfig); 199 | 200 | // Configure the created profile (intent plugin) 201 | var profileConfig2 = { 202 | "PROFILE_NAME": "ZebraReactNativeDemo", 203 | "PROFILE_ENABLED": "true", 204 | "CONFIG_MODE": "UPDATE", 205 | "PLUGIN_CONFIG": { 206 | "PLUGIN_NAME": "INTENT", 207 | "RESET_CONFIG": "true", 208 | "PARAM_LIST": { 209 | "intent_output_enabled": "true", 210 | "intent_action": "com.zebra.reactnativedemo.ACTION", 211 | "intent_delivery": "2" 212 | } 213 | } 214 | }; 215 | this.sendCommand("com.symbol.datawedge.api.SET_CONFIG", profileConfig2); 216 | 217 | // Give some time for the profile to settle then query its value 218 | setTimeout(() => { 219 | this.sendCommand("com.symbol.datawedge.api.GET_ACTIVE_PROFILE", ""); 220 | }, 1000); 221 | } 222 | 223 | datawedge65() 224 | { 225 | console.log("Datawedge 6.5 APIs are available"); 226 | 227 | this.state.dwVersionText = "6.5 or higher."; 228 | 229 | // Instruct the API to send 230 | this.sendCommandResult = "true"; 231 | this.state.lastApiVisible = true; 232 | } 233 | 234 | commandReceived(commandText) 235 | { 236 | this.state.lastApiText = commandText; 237 | this.setState(this.state); 238 | } 239 | 240 | enumerateScanners(enumeratedScanners) 241 | { 242 | var humanReadableScannerList = ""; 243 | for (var i = 0; i < enumeratedScanners.length; i++) 244 | { 245 | console.log("Scanner found: name= " + enumeratedScanners[i].SCANNER_NAME + ", id=" + enumeratedScanners[i].SCANNER_INDEX + ", connected=" + enumeratedScanners[i].SCANNER_CONNECTION_STATE); 246 | humanReadableScannerList += enumeratedScanners[i].SCANNER_NAME; 247 | if (i < enumeratedScanners.length - 1) 248 | humanReadableScannerList += ", "; 249 | } 250 | this.state.enumeratedScannersText = humanReadableScannerList; 251 | } 252 | 253 | activeProfile(theActiveProfile) 254 | { 255 | this.state.activeProfileText = theActiveProfile; 256 | this.setState(this.state); 257 | } 258 | 259 | barcodeScanned(scanData, timeOfScan) 260 | { 261 | var scannedData = scanData["com.symbol.datawedge.data_string"]; 262 | var scannedType = scanData["com.symbol.datawedge.label_type"]; 263 | console.log("Scan: " + scannedData); 264 | this.state.scans.unshift({ data: scannedData, decoder: scannedType, timeAtDecode: timeOfScan }); 265 | console.log(this.state.scans); 266 | this.setState(this.state); 267 | } 268 | 269 | render() { 270 | return ( 271 | 272 | 273 | Zebra ReactNative DataWedge Demo 274 | Information / Configuration 275 | DataWedge version: 276 | {this.state.dwVersionText} 277 | Active Profile 278 | {this.state.activeProfileText} 279 | { this.state.lastApiVisible && 280 | Last API message 281 | } 282 | { this.state.lastApiVisible && 283 | {this.state.lastApiText} 284 | } 285 | Available scanners: 286 | {this.state.enumeratedScannersText} 287 | 288 | {this.state.ean8checked = !this.state.ean8checked;this.setDecoders(); this.setState(this.state)}} 293 | /> 294 | {this.state.ean13checked = !this.state.ean13checked;this.setDecoders(); this.setState(this.state)}} 299 | /> 300 | 301 | 302 | {this.state.code39checked = !this.state.code39checked;this.setDecoders(); this.setState(this.state)}} 307 | /> 308 | {this.state.code128checked = !this.state.code128checked;this.setDecoders(); this.setState(this.state)}} 313 | /> 314 | 315 | {this.state.scanButtonVisible && 316 |