
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
com-darryncampbell-cordova-plugin-intent
Advanced tools
General purpose intent shim layer for cordova appliations on Android. Handles various techniques for sending and receiving intents.
Note: this is the current underlying implementation for https://www.npmjs.com/package/@ionic-native/web-intent and https://ionicframework.com/docs/native/web-intent/
If you are installing this plugin along with cordova-plugin-camera you MUST install cordova-plugin-camera first.
This Cordova plugin provides a general purpose shim layer for the Android intent mechanism, exposing various ways to handle sending and receiving intents.
This project uses code released under the following MIT projects:
This plugin defines a window.plugins.intentShim
object which provides an API for interacting with the Android intent mechanism on any Android device.
An example application is available at https://github.com/darryncampbell/plugin-intent-api-exerciser to demonstrate the API and can be used to test the functionality.
cordova plugin add https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent.git
cordova plugin add com-darryncampbell-cordova-plugin-intent
Please use the latest PhoneGap cli when including this plugin, please refer to Issue 63 for context.
Registers a broadcast receiver for the specified filters
window.plugins.intentShim.registerBroadcastReceiver(filters, callback);
The intentShim.registerBroadcastReceiver
function registers a dynamic broadcast receiver for the specified list of filters and invokes the specified callback when any of those filters are received
Any existing broadcast receiver is unregistered when this method is called. To register for multiple types of broadcast, specify multiple filters.
Register a broadcast receiver for two filters:
window.plugins.intentShim.registerBroadcastReceiver({
filterActions: [
'com.darryncampbell.cordova.plugin.broadcastIntent.ACTION',
'com.darryncampbell.cordova.plugin.broadcastIntent.ACTION_2'
]
},
function(intent) {
console.log('Received broadcast intent: ' + JSON.stringify(intent.extras));
}
);
Unregisters the broadcast receiver
window.plugins.intentShim.unregisterBroadcastReceiver();
The intentShim.unregisterBroadcastReceiver
function unregisters the broadcast receiver registered with intentShim.registerBroadcastReceiver(filters, callback);
. No further broadcasts will be received for any registered filter after this call.
The developer is responsible for calling unregister / register when their application goes into the background or comes back to the foreground, if desired.
Unregister the broadcast receiver when the application receives an onPause event:
bindEvents: function() {
document.addEventListener('pause', this.onPause, false);
},
onPause: function()
{
window.plugins.intentShim.unregisterBroadcastReceiver();
}
Sends a broadcast intent
window.plugins.intentShim.sendBroadcast(action, extras, successCallback, failureCallback);
The intentShim.sendBroadcast
function sends an Android broadcast intent with a specified action
Send a broadcast intent to a specified action that contains a random number in the extras
window.plugins.intentShim.startActivity(
{
action: "com.darryncampbell.cordova.plugin.intent.ACTION",
extras: {
'random.number': Math.floor((Math.random() * 1000) + 1)
}
},
function() {},
function() {alert('Failed to open URL via Android Intent')}
);
Returns the content of the intent used whenever the application activity is launched
window.plugins.intentShim.onIntent(callback);
The intentShim.onIntent
function returns the intent which launched the Activity and maps to the Android Activity's onNewIntent() method, https://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent). The registered callback is invoked whenever the activity is launched
By default the android application will be created with launch mode set to 'SingleTop'. If you wish to change this to 'SingleTask' you can do so by modifying config.xml
as follows:
<platform name="android">
...
<preference name="AndroidLaunchMode" value="singleTask"/>
</platform>
See https://www.mobomo.com/2011/06/android-understanding-activity-launchmode/ for more information on the differences between the two.
Registers a callback to be invoked
window.plugins.intentShim.onIntent(function (intent) {
console.log('Received Intent: ' + JSON.stringify(intent.extras));
});
Starts a new activity using an intent built from action, url, type, extras or some subset of those parameters
window.plugins.intentShim.startActivity(params, successCallback, failureCallback);
The intentShim.startActivity
function maps to Android's activity method startActivity, https://developer.android.com/reference/android/app/Activity.html#startActivity(android.content.Intent) to launch a new activity.
Some common actions are defined as constants in the plugin, see below.
Launch the maps activity
window.plugins.intentShim.startActivity(
{
action: window.plugins.intentShim.ACTION_VIEW,
url: 'geo:0,0?q=London'
},
function() {},
function() {alert('Failed to open URL via Android Intent')}
);
Launch the web browser
window.plugins.intentShim.startActivity(
{
action: window.plugins.intentShim.ACTION_VIEW,
url: 'http://www.google.co.uk'
},
function() {},
function() {alert('Failed to open URL via Android Intent')}
);
Retrieves the intent that launched the activity
window.plugins.intentShim.getIntent(resultCallback, failureCallback);
The intentShim.getIntent
function maps to Android's activity method getIntent, https://developer.android.com/reference/android/app/Activity.html#getIntent() to return the intent that started this activity.
window.plugins.intentShim.getIntent(
function(intent)
{
console.log('Action' + JSON.stringify(intent.action));
var intentExtras = intent.extras;
if (intentExtras == null)
intentExtras = "No extras in intent";
console.log('Launch Intent Extras: ' + JSON.stringify(intentExtras));
},
function()
{
console.log('Error getting launch intent');
});
Starts a new activity and return the result to the application
window.plugins.intentShim.startActivityForResult(params, resultCallback, failureCallback);
The intentShim.startActivityForResult
function maps to Android's activity method startActivityForResult, https://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int) to launch a new activity and the resulting data is returned via the resultCallback.
Some common actions are defined as constants in the plugin, see below.
Pick an Android contact
window.plugins.intentShim.startActivityForResult(
{
action: window.plugins.intentShim.ACTION_PICK,
url: "content://com.android.contacts/contacts",
requestCode: 1
},
function(intent)
{
if (intent.extras.requestCode == 1)
{
console.log('Picked contact: ' + intent.data);
}
},
function()
{
console.log("StartActivityForResult failure");
});
The following constants are defined in the plugin for use in JavaScript
Tested with Cordova version 6.5.0 and Cordova Android version 6.2.1
FAQs
General purpose intent shim layer for cordova appliations on Android. Handles various techniques for sending and receiving intents.
The npm package com-darryncampbell-cordova-plugin-intent receives a total of 2,552 weekly downloads. As such, com-darryncampbell-cordova-plugin-intent popularity was classified as popular.
We found that com-darryncampbell-cordova-plugin-intent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.