diff --git a/types/react-native-datawedge-intents/index.d.ts b/types/react-native-datawedge-intents/index.d.ts new file mode 100644 index 0000000000..0d5dbcd4c6 --- /dev/null +++ b/types/react-native-datawedge-intents/index.d.ts @@ -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 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface ExtrasObject { + action: string; + extras?: object; +} + +interface FilterObject { + filterActions: ReadonlyArray; + filterCategories: ReadonlyArray; +} + +declare const DataWedgeIntents: { + sendBroadcastWithExtras: (extrasObject: ExtrasObject) => void; + registerBroadcastReceiver: (filter: FilterObject) => void; +}; + +export = DataWedgeIntents; diff --git a/types/react-native-datawedge-intents/react-native-datawedge-intents-tests.ts b/types/react-native-datawedge-intents/react-native-datawedge-intents-tests.ts new file mode 100644 index 0000000000..c9ed3bb1f4 --- /dev/null +++ b/types/react-native-datawedge-intents/react-native-datawedge-intents-tests.ts @@ -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 + }); +} diff --git a/types/react-native-datawedge-intents/tsconfig.json b/types/react-native-datawedge-intents/tsconfig.json new file mode 100644 index 0000000000..30c66e7159 --- /dev/null +++ b/types/react-native-datawedge-intents/tsconfig.json @@ -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" + ] +} diff --git a/types/react-native-datawedge-intents/tslint.json b/types/react-native-datawedge-intents/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-datawedge-intents/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }