0

I'm created small react native app for Zebra TC20 barcode scanner. It works just fine. The main issue I need to solve is somehow open my app on scan button press...

By default when scan button is pressed and if my app is not running the DWDemo app launches and shows scanned data. And I need that by default would be opened my app.

I'm using https://github.com/darryncampbell/react-native-datawedge-intents to get barcodes. And it uses DeviceEventEmitter.

Maybe there are some techniques to register listener in foreground for specific event and start the app ?

Kin
  • 4,466
  • 13
  • 54
  • 106

1 Answers1

1

That React module (which I'm the author of by the way :) ) is hardcoded to assume that scan data will be sent via a Broadcast Intent. I did it this way because the DataWedge API can only communicate with the application via Broadcast Intents however scan data is not sent via the DataWedge API, it is sent via the DataWedge Intent output plugin which CAN support both startActivity and startService.

By default the device, out of the box, will not launch DWDemo when a barcode is scanned. If you launch DataWedge you will see a number of profiles, one of which will be the 'default' profile which is used when no other profile is in effect (i.e. no app associated with a specific profile is in the foreground) - you can configure this default profile to specify Intent delivery as StartActivity and I assume whatever profile is default on your device is invoking the DWDemo app.

So, to achieve what you want to achieve you would need to:

Darryn Campbell
  • 1,441
  • 10
  • 13
  • On a related note, I see a similar question posed yesterday on the Zebra developer portal (https://developer.zebra.com/forum/24987). I presume you are the same author? Unfortunately owing to some technical issue I am unable to reply on the dev portal – Darryn Campbell Feb 26 '20 at 08:43
  • So If i understood correctly in my situation the profile I'm using currently is configed just to pass data and I need to config it not to pass data, but start the app and than I need to get Intent in Java. So basically no need using your react native module? – Kin Feb 26 '20 at 09:30
  • Also the default profile is Profile0 which don't have the ability to associate any apps. There are 2 more profiles Launcher which seems to start apps when but didn't work for me and DWDemo profile. I also tried to export all profiles and change every occurrence of DWDemo app to my own app name and also no luck. – Kin Feb 26 '20 at 09:36
  • 1
    You want a scan to launch your application and the easiest way you can achieve that is to have a scan invoke your app via StartActivity. When anything calls StartActivity it does so via an Intent and DataWedge will add the scan data to this Intent so after your activity is launched you can call getIntent() to see what the scan data was. You can easily do that in a Native app & I can point you to samples but I am unsure how to call getIntent() from ReactNative due to my inexperience. – Darryn Campbell Feb 26 '20 at 09:38
  • A profile will be associated with the foreground app. I started talking about 'default app' because I assumed you wanted to invoke your app regardless of what activity is displayed. "Launcher" is in effect when the home screen is displayed and you can delete that if you need to. DWDemo profile will only be in effect when DWDemo is in the foreground. I'm not sure why DWDemo is being launched for you. If you want to send me your exported DataWedge configuration I can take a look – Darryn Campbell Feb 26 '20 at 09:41
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/208550/discussion-between-kin-and-darryn-campbell). – Kin Feb 26 '20 at 09:42