2.0.2 • Published 3 years ago

@elastosfoundation/elastos-cordova-plugin-intent v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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>
    <platform name="android">
        <preference name="AndroidLaunchMode" value="singleTask" />
    </platform>

Supported Platforms

  • Android
  • iOS

Classes

Typedefs

IntentManager

Kind: global class

appManager.sendIntent(action, params, onSuccess, onError)

Send a intent by action.

Kind: instance method of IntentManager

ParamTypeDescription
actionstringThe intent action.
paramsObjectThe intent params.

appManager.addIntentListener(callback: (msg: ReceivedIntent)=>void)

Set intent listener for message callback.

Kind: instance method of IntentManager

ParamTypeDescription
callback(msg: ReceivedIntent)=>voidThe function receive the intent.

appManager.sendIntentResponse(action, result, intentId, onSuccess, onError)

Send a intent respone by id.

Kind: instance method of IntentManager

ParamTypeDescription
actionstringThe intent action.
resultObjectThe intent respone result.
intentIdlongThe intent id.

ReceivedIntent : Object

Information about an intent request.

Kind: IntentPlugin typedef Properties

NameTypeDescription
actionstringThe action requested from the receiving application.
paramsanyCustom intent parameters provided by the calling application.
intentIdnumberThe intent id of the calling application.
originalJwtRequest?stringIn case the intent comes from outside essentials and was received as a JWT, this JWT is provided here.