How to configure a profile and receive a Datawedge broadcast receiver intent programatically in an Angular Ionic app?

S Sobia Shahbaz 1 month ago
54 1 1

Dear Zebra Support Team,

I hope this message finds you well. I am reaching out for assistance with an issue I’m encountering while working with DataWedge on a Zebra TC26 device running Android 14 and DataWedge version 15.0.9.

Issue Description
I am trying to configure a profile programmatically on DataWedge and retrieve the list of DataWedge profiles using the com.symbol.datawedge.api.GET_PROFILES_LIST API.

However, despite successfully sending the intent (confirmed by the log: "Intent sent successfully to get DataWedge profiles list"), I am not receiving any response from DataWedge. The broadcast receiver does not seem to capture the intent containing the profiles list.

Current Implementation

1. Profile Creation and Configuration
I am dynamically creating and configuring a DataWedge profile named "ABC" using the following steps:
Associate the profile with my app’s package name.
Configure the INTENT plugin to use a custom intent action (<packageName>.scan) and enable BROADCAST delivery.
Set the Intent Category to android.intent.category.DEFAULT.

Here’s the relevant code snippet for profile configuration:


public profileIntentOutputConfig(profileName: string, scanIntentName: string): DataWedgeProfileConfig {
   return {
       PROFILE_NAME: profileName,
       PROFILE_ENABLED: 'true',
       CONFIG_MODE: 'UPDATE',
       PLUGIN_CONFIG: [
           {
               PLUGIN_NAME: 'INTENT',
               RESET_CONFIG: 'true',
               PARAM_LIST: {
                   intent_output_enabled: 'true',
                   intent_action: scanIntentName,
                   intent_delivery: DataWedgeIntentDelivery.BROADCAST,
                   intent_category: 'android.intent.category.DEFAULT',
               },
           },
           // Other plugin configurations...
       ]
   };
}

2. Sending the Intent
I am sending the following intent to request the profiles list:
const intent = {
   action: 'com.symbol.datawedge.api.ACTION',
   extras: {
       'com.symbol.datawedge.api.GET_PROFILES_LIST': ''
   }
};

(window as any).plugins.intentShim.sendBroadcast(intent, successCallback, errorCallback);

The log "Intent sent successfully to get DataWedge profiles list" confirms that the intent is sent successfully.

3. Broadcast Receiver
I have set up a broadcast receiver to listen for the response:
(window as any).plugins.intentShim.registerBroadcastReceiver(
   {
       filterActions: [
           'com.symbol.datawedge.api.RESULT_ACTION'
       ],
       filterCategories: [
           'android.intent.category.DEFAULT'
       ]
   },
   (intent) => {
       console.log('Received Intent:', intent);
       if (intent.action === 'com.symbol.datawedge.api.RESULT_ACTION') {
           const profilesList = intent.extras['com.symbol.datawedge.api.RESULT_GET_PROFILES_LIST'];
           if (profilesList) {
               console.log('DataWedge Profiles List:', profilesList);
           }
       }
   }
);

However, the broadcast receiver does not log any intents, and I am unable to retrieve the profiles list.

What I’ve Tried
Verified that the DataWedge profile is correctly configured with the INTENT plugin.
Ensured that the >Intent Category is set to android.intent.category.DEFAULT.
Restarted the DataWedge service on the device.
Confirmed that the app has the necessary permissions:
RECEIVE_BOOT_COMPLETED
WAKE_LOCK
FOREGROUND_SERVICE

Request for Assistance
Could you please help me identify what might be wrong with my implementation? Specifically:

Are there any additional configurations required in the DataWedge profile to enable the GET_PROFILES_LIST API?
Is there a known issue with DataWedge version 15.0.9 or Android 14 that might be causing this behavior?
Are there any debugging steps I can take to further investigate why the broadcast receiver is not capturing the response?

Any guidance or suggestions would be greatly appreciated! Please let me know if you need additional information or logs from my side.

Thank you for your time and support!
 

Please Register or Login to post a reply

1 Replies

A Adam Stein

It looks like you've set up everything correctly, but there are a few things you can check and try to troubleshoot why you're not receiving the response from DataWedge. Let's go through them step by step:

1. Check DataWedge Logging for Errors

Since DataWedge is not sending a response, check if the GET_PROFILES_LIST intent is being processed at all:

  • Open DataWedge > Settings > Enable DataWedge Logging.
  • Use ADB Logcat to check if any errors appear when you send the intent:

    adb logcat -s DataWedge
    
  • If there’s an issue with intent handling, you should see relevant logs.

2. Verify Broadcast Receiver Setup

Ensure that your broadcast receiver is actually running and listening to the correct intents. Some things to check:

  • The response from DataWedge should contain an Intent action of com.symbol.datawedge.api.RESULT_ACTION. Your receiver should be listening for this.
  • Ensure your receiver is properly registered.

Try registering it dynamically instead of using intentShim:

Test with Java/Kotlin

If possible, test with native Java/Kotlin code to check if the issue is with intentShim:

BroadcastReceiver dataWedgeReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals("com.symbol.datawedge.api.RESULT_ACTION")) {
            Bundle extras = intent.getExtras();
            if (extras != null && extras.containsKey("com.symbol.datawedge.api.RESULT_GET_PROFILES_LIST")) {
                ArrayList<String> profiles = extras.getStringArrayList("com.symbol.datawedge.api.RESULT_GET_PROFILES_LIST");
                Log.d("DataWedge", "Profiles: " + profiles);
            }
        }
    }
};

// Register the receiver dynamically
IntentFilter filter = new IntentFilter();
filter.addAction("com.symbol.datawedge.api.RESULT_ACTION");
context.registerReceiver(dataWedgeReceiver, filter);

If this works, the issue may be related to how intentShim is handling broadcasts.

3. Ensure DataWedge Has Permission to Send Broadcasts

Starting from Android 12+, broadcast receivers need explicit permissions to receive implicit broadcasts.

Try adding the following to your AndroidManifest.xml:

<receiver android:name=".DataWedgeReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="com.symbol.datawedge.api.RESULT_ACTION"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</receiver>

Also, request RECEIVE_BROADCAST permission:

<uses-permission android:name="android.permission.RECEIVE_BROADCAST"/>

4. Force DataWedge to Send Result via "SEND_RESULT"

In some cases, DataWedge doesn’t send responses automatically. You can explicitly request a response using the SEND_RESULT flag.

Modify your GET_PROFILES_LIST request like this:

const intent = {
   action: 'com.symbol.datawedge.api.ACTION',
   extras: {
       'com.symbol.datawedge.api.GET_PROFILES_LIST': '',
       'SEND_RESULT': 'LAST_RESULT'
   }
};

This forces DataWedge to send the response as the last known result.

5. Check If DataWedge is Running in Foreground

Sometimes, DataWedge might not process requests properly if it is inactive or crashes in the background.

Try restarting DataWedge manually:

  1. Open the DataWedge app.
  2. Go to Settings > Disable DataWedge > Enable DataWedge.
  3. Restart your app and try again.

6. Verify That Other Intents Work

To determine if the issue is with GET_PROFILES_LIST specifically, try sending another API request, such as GET_VERSION_INFO:

const intent = {
   action: 'com.symbol.datawedge.api.ACTION',
   extras: {
       'com.symbol.datawedge.api.GET_VERSION_INFO': ''
   }
};

If this also doesn’t return a response, the problem may be with the broadcast setup.

7. Try Using "START_ACTIVITY" Instead of "BROADCAST"

As a last resort, switch from BROADCAST to START_ACTIVITY in your DataWedge configuration:

intent_delivery: 'START_ACTIVITY'

This will open your app when a scan is received.

Next Steps

  • ✅ Enable DataWedge logging and check logs with adb logcat -s DataWedge.
  • ✅ Test GET_VERSION_INFO to see if any API calls work.
  • ✅ Register a native broadcast receiver in Java/Kotlin and check if the issue is with intentShim.
  • ✅ Add the necessary permissions in AndroidManifest.xml.
  • ✅ Explicitly request a response with SEND_RESULT.

. . . . .

CONTACT
Can’t find what you’re looking for?