https://github.com/elastos/elastos.cordova.plugins.intent
https://github.com/elastos/elastos.cordova.plugins.intent
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/elastos/elastos.cordova.plugins.intent
- Owner: elastos
- Created: 2021-03-10T03:23:08.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-29T05:07:59.000Z (over 3 years ago)
- Last Synced: 2025-02-03T17:08:00.074Z (4 months ago)
- Language: Swift
- Size: 111 KB
- Stars: 2
- Watchers: 25
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
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.
```js
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(intentManager);
}
```## Usage
### In typescript file
```ts
declare let intentManager: IntentPlugin.IntentManager;
```---
## Installation```bash
cordova plugin add @elastosfoundation/elastos-cordova-plugin-intent
```## Cofigure
### tsconfig.app.json
```json
"types": [
"@elastosfoundation/elastos-cordova-plugin-intent"
]
```### config.xml
- Specific IntentRedirecturlFilter, with custom scheme for android vs https url for ios. such as
```xml
applinks:XXX.sample.net
applinks:XXX.sample.net
```- 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.
```xml
```
## Supported Platforms- Android
- iOS## Classes
## Typedefs
-
ReceivedIntent :Object
-
Information about an intent request.
## IntentManager
**Kind**: global class
* [IntentManager](#IntentManager)
* [.sendIntent(action, params](#IntentManager+sendIntent)
* [.addIntentListener(callback: (msg: ReceivedIntent)=>void)](#IntentManager+addIntentListener)
* [.sendIntentResponse(action, result, intentId)](#IntentManager+sendIntentResponse)
### appManager.sendIntent(action, params, onSuccess, [onError])
Send a intent by action.
**Kind**: instance method of [IntentManager
](#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
](#IntentManager)
| Param | Type | Description |
| --- | --- | --- |
| callback | [(msg: ReceivedIntent)=>void
](#onReceiveIntent) | The function receive the intent. |
### appManager.sendIntentResponse(action, result, intentId, onSuccess, [onError])
Send a intent respone by id.
**Kind**: instance method of [IntentManager
](#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. |