1.4.0 • Published 4 months ago

capacitor-intents-for-android v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

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
ParamType
options{ filters: {}; categories?: {}; }
callback(data: { key: string: any; }) => void

Returns: any


unregisterBroadcastReceiver(...)

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

Returns: any


sendBroadcastIntent(...)

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

Returns: any


1.4.0

4 months ago

1.3.1

6 months ago

1.3.0

6 months ago

2.0.0

6 months ago

1.3.0-next.5

6 months ago

1.3.0-next.4

6 months ago

1.3.4

6 months ago

1.3.0-next.3

6 months ago

1.3.0-next.2

6 months ago

1.3.0-next.1

6 months ago