Simple intent tools for Capacitor on Android platform.
npm install capacitor-intents-android
npx cap sync
See example-app
in packages
folder.
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);
}
);
registerBroadcastReceiver(options: { filters: string[]; }, callback: (data: { [key: string]: any; }) => void) => any
Param | Type |
---|---|
options |
{ filters: {}; } |
callback |
(data: { [key: string]: any; }) => void |
Returns: any
unregisterBroadcastReceiver(options: { id: string; }) => any
Param | Type |
---|---|
options |
{ id: string; } |
Returns: any
sendBroadcastIntent(options: { action: string; extras: { [key: string]: any; }; }) => any
Param | Type |
---|---|
options |
{ action: string; extras: { [key: string]: any; }; } |
Returns: any