darryncampbell / darryncampbell-cordova-plugin-intent

General purpose intent shim layer for cordova appliations on Android. Handles various techniques for sending and receiving intents.
MIT License
86 stars 134 forks source link

Duplicate barcode #69

Closed davidpadych closed 4 years ago

davidpadych commented 5 years ago

Hello,

i apologize for my English... i am using your plugin with Data Wedge profile (set according to your blog post).

Everything works as it is, scans the codes, and I come across a case where sometimes (possibly between 2 different codes) when I do it so quickly (<2s) the received intent (barcode) is the same as the previous one.

I do not know what I am doing wrong? is it possible that there would be some cache, for example, in setting a date wedge profile or some timeout?

thank you for any help :)

Version: com-darryncampbell-cordova-plugin-intent 1.1.5 Ionic 3.7.1 HW: Zebra TC-25 (Android 6.0)

Code (typescript):

private registerBroadcast() {
        console.log('register broadcast intent');

        window['plugins'].intentShim.registerBroadcastReceiver({
                filterActions: ['cz.myapp.scanner', 'com.symbol.datawedge.api.RESULT_ACTION'],
                filterCategories: ['com.android.intent.category.DEFAULT']
            },
            (intent) => {
                console.log('received intent: ', intent.extras);

                if (intent.extras['com.symbol.datawedge.data_string']) {
                    this.events.publish('reader:barcode', intent.extras['com.symbol.datawedge.data_string']);
                }
            }
        );
    }

    private unregisterBroadcast() {
        console.log('unregister broadcast intent');

        window['plugins'].intentShim.unregisterBroadcastReceiver();
    }
darryncampbell commented 5 years ago

Hi, is this reproducible with the Zebra Ionic Demo at https://github.com/Zebra/ZebraIonicDemo ?

davidpadych commented 5 years ago

Code looks the same and dependecy (your plugin) too... I can try to build this project and test it

darryncampbell commented 5 years ago

Please do and if you can reproduce with the demo app then I'll take a look. I definitely have not seen this before but it could be related to versions / device / Operating system or any number of variables.

davidpadych commented 5 years ago

I've been able to reproduce the bug even on the application ZebraIonicDemo...

just get 20 different barcode (code128) and load them fast ... 2x to read the new code read the previous (see screenshots)

DataWedge App version 6.6.49 Android 7.1.2 Zebra TC25

1 2 3

darryncampbell commented 5 years ago

I don't see the same with a TC25 here, it is running DataWedge 6.7 but that should not make a difference. Is it possible you are scanning the same barcode twice inadvertently? Perhaps enable Picklist mode in your DataWedge Profile (Barcode Input --> Reader Params --> Picklist --> Software), then only the barcode below the reticle will be decoded.

davidpadych commented 5 years ago

I really did not scan the same code twice... I try the settings in the datawedge profile.

davidpadych commented 5 years ago

even after setting up a Picklist - Software, same behavior ...

I've also tried this plugin (https://github.com/BlueFletch/motorola-datawedge-cordova-plugin) and the behavior is the same.

It must be somewhere in setting up that DataWedge profile. DWDemo (DataWedge demo app) uses the Intent Output -> Intent delivery -> Send via startActivity and duplicates are not used.

I use Broadcast intent just like ZebraIonicDemo, otherwise the setting looks exactly the same.

darryncampbell commented 5 years ago

You should be able to use the getIntent() method of this plugin to retrieve the Intent sent by StartActivity, if that is an option for you

davidpadych commented 5 years ago

and how to use it? Every time I run an app, getIntent () performs only once ... nothing happens after every code is scaned.

darryncampbell commented 5 years ago

Or onIntent(). There are examples of use in the read me: https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent

davidpadych commented 5 years ago

Thanks, maybe I'm good with some solution.

redwolf2 commented 5 years ago

Another idea worth trying out might be to always use NgZone.run() in the receiving event. Like:

import {NgZone} from '@angular/core';

constructior(public zone: NgZone) {
}

private registerBroadcast() {
    console.log('register broadcast intent');
    window['plugins'].intentShim.registerBroadcastReceiver({
        filterActions: ['cz.myapp.scanner', 'com.symbol.datawedge.api.RESULT_ACTION'],
    filterCategories: ['com.android.intent.category.DEFAULT']
    },
    (intent) => {
        this.zone.run(() => {
        console.log('received intent: ', intent.extras);
            if (intent.extras['com.symbol.datawedge.data_string']) {
                this.events.publish('reader:barcode', intent.extras['com.symbol.datawedge.data_string']);
            }
        });
    }
);
darryncampbell commented 5 years ago

Can this be closed?