Skip to content

elastos/Elastos.Essentials.Plugins.Intent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

title description
IntentManager
This is an internal plugin for Elastos Essentials in order to manage internal and external inter-app communications through "intents".

elastos-essentials-plugin-intent

This plugin defines a global cordova.essentialsIntentManager object, which provides an API for essentials 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(essentialsIntentManager);
}

Usage

In typescript file

declare let essentialsIntentManager: EssentialsIntentPlugin.IntentManager;

Installation

    cordova plugin add elastos-essentials-plugin-intent

Configure

tsconfig.app.json

    "types": [
        "elastos-essentials-plugin-intent"
        ]

config.xml

  • Add InternalIntentFilters, RawUrlIntentFilters and IntentRedirecturlFilter.
    <preference name="InternalIntentFilters" value="https://did.elastos.net https://wallet.elastos.net https://hive.elastos.net https://contact.elastos.net https://scanner.elastos.net" />
    <preference name="IntentRedirecturlFilter" value="https://essentials.elastos.net" />
    <preference name="RawUrlIntentFilters" value="wc: https://wallet.elastos.net/wc:" />
    <platform name="android">
        <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:host="essentials.elastos.net" android:pathPattern="/.*" android:scheme="https" />
            </intent-filter>
            <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:host="did.elastos.net" android:pathPattern="/.*" android:scheme="https" />
            </intent-filter>
            <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:host="wallet.elastos.net" android:pathPattern="/.*" android:scheme="https" />
            </intent-filter>
            <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:host="hive.elastos.net" android:pathPattern="/.*" android:scheme="https" />
            </intent-filter>
            <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:host="contact.elastos.net" android:pathPattern="/.*" android:scheme="https" />
            </intent-filter>
            <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:host="scanner.elastos.net" android:pathPattern="/.*" android:scheme="https" />
            </intent-filter>
        </config-file>
    </platform>
    <platform name="ios">
        <preference name="SwiftVersion" value="5.2" />
        <preference name="UseSwiftLanguageVersion" value="5.2" />
        <config-file parent="com.apple.developer.associated-domains" target="*-Debug.plist">
            <array>
                <string>applinks:essentials.elastos.net</string>
                <string>applinks:launcher.elastos.net</string>
                <string>applinks:did.elastos.net</string>
                <string>applinks:wallet.elastos.net</string>
                <string>applinks:hive.elastos.net</string>
                <string>applinks:contact.elastos.net</string>
                <string>applinks:scanner.elastos.net</string>
            </array>
        </config-file>
        <config-file parent="com.apple.developer.associated-domains" target="*-Release.plist">
            <array>
                <string>applinks:essentials.elastos.net</string>
                <string>applinks:launcher.elastos.net</string>
                <string>applinks:did.elastos.net</string>
                <string>applinks:wallet.elastos.net</string>
                <string>applinks:hive.elastos.net</string>
                <string>applinks:contact.elastos.net</string>
                <string>applinks:scanner.elastos.net</string>
            </array>
        </config-file>
    </platform>
  • In android platform
    <platform name="android">
        <preference name="AndroidLaunchMode" value="singleTask" />
    </platform>

Supported Platforms

  • Android
  • iOS

Classes

IntentManager

Typedefs

ReceivedIntent : Object

Information about an intent request.

IntentSource : enum

Information about an intent from.

IntentManager

Kind: global class

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

Send an 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 an 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.

ReceivedIntent : Object

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.
from IntentSource From 'internal' or 'external'..

IntentSource : enum

Information about an intent request.

Kind: IntentPlugin enum Properties

Name Value Description
Internal "INTERNAL" The intent from internal.
External "EXTERNAL" The intent from external.