DefinitelyTyped/types/react-native-datawedge-intents/react-native-datawedge-intents-tests.ts
DerZersaeger bf28fce907
Added react-native-datawedge-intents (#43516)
* [react-native-datawedge-intents] Initial commit

* Fix lint errors

* Apply suggestions from @uniqueiniquity
2020-04-01 13:03:36 -07:00

27 lines
848 B
TypeScript

import DataWedgeIntents from 'react-native-datawedge-intents';
// Register a receiver for the barcode scans with the appropriate action
DataWedgeIntents.registerBroadcastReceiver({
filterActions: [
'com.zebra.reactnativedemo.ACTION',
'com.symbol.datawedge.api.RESULT_ACTION'
],
filterCategories: [
'android.intent.category.DEFAULT'
]
});
// Initiate a scan (you could also press the trigger key)
sendCommand('com.symbol.datawedge.api.SOFT_SCAN_TRIGGER', 'TOGGLE_SCANNING');
function sendCommand(extraName: string, extraValue: any) {
const broadcastExtras = {
[extraName]: extraValue,
SEND_RESULT: "false" // need to be passed as string
};
DataWedgeIntents.sendBroadcastWithExtras({
action: "com.symbol.datawedge.api.ACTION",
extras: broadcastExtras
});
}