title: IntentManager description: This is an plugin for Elastos Cordova in order to manage external inter-app communications through "intents".
@elastosfoundation/elastos-cordova-plugin-intent
This plugin defines a global cordova.intentManager
object, which provides an API for intent manager library.
Although in the global scope, it is not available until after the deviceready
event.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(intentManager);
}
Usage
In typescript file
declare let intentManager: IntentPlugin.IntentManager;
Installation
cordova plugin add @elastosfoundation/elastos-cordova-plugin-intent
Cofigure
tsconfig.app.json
"types": [
"@elastosfoundation/elastos-cordova-plugin-intent"
]
config.xml
- Specific IntentRedirecturlFilter, with custom scheme for android vs https url for ios. such as
<platform name="android">
<preference name="IntentRedirecturlFilter" value="XXX://" />
<config-file parent="/manifest/application/activity" target="AndroidManifest.xml">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="XXX" />
</intent-filter>
</config-file>
</platform>
<platform name="ios">
<preference name="IntentRedirecturlFilter" value="https://XXX.sample.net" />
<config-file parent="com.apple.developer.associated-domains" target="*-Debug.plist">
<array>
<string>applinks:XXX.sample.net</string>
</array>
</config-file>
<config-file parent="com.apple.developer.associated-domains" target="*-Release.plist">
<array>
<string>applinks:XXX.sample.net</string>
</array>
</config-file>
</platform>
-
About such as "XXX.sample.net" configuring in ios please reference: https://developer.elastos.org/build/elastos/trinity-native/quick_start/#configuring-your-domain-for-ios-apps
-
In android platform, need add "AndroidLaunchMode = singleTask" for receive external intent in the same activity.
<platform name="android">
<preference name="AndroidLaunchMode" value="singleTask" />
</platform>
Supported Platforms
- Android
- iOS
Classes
Typedefs
-
ReceivedIntent :
Object
-
Information about an intent request.
IntentManager
Kind: global class
appManager.sendIntent(action, params, onSuccess, [onError])
Send a intent by action.
Kind: instance method of IntentManager
Param | Type | Description |
---|---|---|
action | string |
The intent action. |
params | Object |
The intent params. |
appManager.addIntentListener(callback: (msg: ReceivedIntent)=>void)
Set intent listener for message callback.
Kind: instance method of IntentManager
Param | Type | Description |
---|---|---|
callback | (msg: ReceivedIntent)=>void |
The function receive the intent. |
appManager.sendIntentResponse(action, result, intentId, onSuccess, [onError])
Send a intent respone by id.
Kind: instance method of IntentManager
Param | Type | Description |
---|---|---|
action | string |
The intent action. |
result | Object |
The intent respone result. |
intentId | long |
The intent id. |
Object
ReceivedIntent : Information about an intent request.
Kind: IntentPlugin typedef Properties
Name | Type | Description |
---|---|---|
action | string |
The action requested from the receiving application. |
params | any |
Custom intent parameters provided by the calling application. |
intentId | number |
The intent id of the calling application. |
originalJwtRequest? | string |
In case the intent comes from outside essentials and was received as a JWT, this JWT is provided here. |