capacitor-intents-for-android
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

capacitor-intents-for-android

Simple intent tools for Capacitor on Android platform.

Install

npm install capacitor-intents-for-android
npx cap sync

Usage

See example-app in packages folder.

Simple Example Zebra Device

Register Listener:

CapacitorIntents.registerBroadcastReceiver({
    filters: ['com.your.custom.action', 'com.symbol.datawedge.api.RESULT_ACTION'],
    categories: ['android.intent.category.DEFAULT']
    },
    // Callback function
    (intent) => {
        console.log('Received Intent: ', intent.extras);
    })

CapacitorIntents.sendBroadcastIntent({ 
    action: 'com.your.custom.action', 
    // You can add as many extra Key : Value Pairs as Needed
    extras: {
        "com.symbol.datawedge.api.SOFT_SCAN_TRIGGER":   "TOGGLE_SCANNING"
        }
    })
    .then(
        (result) => {
            console.log('sendCommand: ', result);
        }
    );

// Profile Creation 
const profileConfig = {
    PROFILE_NAME: "Example Name",
    PROFILE_ENABLED: "true",
    CONFIG_MODE: "UPDATE",
    PLUGIN_CONFIG: {
        PLUGIN_NAME: "INTENT",
        RESET_CONFIG: "true",
        PARAM_LIST: {
            intent_output_enabled: "true", //attention for Zebra true and false are string type
            intent_action: "com.your.custom.action",
            intent_delivery: 2,
        },
    },
};

CapacitorIntents.sendBroadcastIntent({ 
    action: "com.symbol.datawedge.api.ACTION",
    extras: {
        "com.symbol.datawedge.api.SET_CONFIG", 
        profileConfig
    }
});

API

registerBroadcastReceiver(...)

registerBroadcastReceiver(options: { filters: string[]; categories?: string[]; }, callback: (data: { [key: string]: any; }) => void) => any
Param Type
options { filters: {}; categories?: {}; }
callback (data: { [key: string]: any; }) => void

Returns: any


unregisterBroadcastReceiver(...)

unregisterBroadcastReceiver(options: { id: string; }) => any
Param Type
options { id: string; }

Returns: any


sendBroadcastIntent(...)

sendBroadcastIntent(options: { action: string; extras: { [key: string]: any; }; }) => any
Param Type
options { action: string; extras: { [key: string]: any; }; }

Returns: any


Readme

Keywords

Package Sidebar

Install

npm i capacitor-intents-for-android

Weekly Downloads

3

Version

1.4.0

License

MIT

Unpacked Size

33.7 kB

Total Files

20

Last publish

Collaborators

  • detchenkov