Added react-native-datawedge-intents (#43516)

* [react-native-datawedge-intents] Initial commit

* Fix lint errors

* Apply suggestions from @uniqueiniquity
This commit is contained in:
DerZersaeger 2020-04-01 22:03:36 +02:00 committed by GitHub
parent 6b97870ab9
commit bf28fce907
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,21 @@
// Type definitions for react-native-datawedge-intents 0.1
// Project: https://github.com/darryncampbell/react-native-datawedge-intents#readme
// Definitions by: DerZersaeger <https://github.com/DerZersaeger>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface ExtrasObject {
action: string;
extras?: object;
}
interface FilterObject {
filterActions: ReadonlyArray<string>;
filterCategories: ReadonlyArray<string>;
}
declare const DataWedgeIntents: {
sendBroadcastWithExtras: (extrasObject: ExtrasObject) => void;
registerBroadcastReceiver: (filter: FilterObject) => void;
};
export = DataWedgeIntents;

View File

@ -0,0 +1,26 @@
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
});
}

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"esModuleInterop": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-native-datawedge-intents-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }