Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Web Intent

Improve this doc

This Plugin provides a general purpose shim layer for the Android intent mechanism, exposing various ways to handle sending and receiving intents.

Repo: https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add com-darryncampbell-cordova-plugin-intent
    $ npm install --save @ionic-native/web-intent@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

For usage information please refer to the plugin's Github repo.

import { WebIntent } from '@ionic-native/web-intent';

constructor(private webIntent: WebIntent) { }

...

const options = {
  action: this.webIntent.ACTION_VIEW,
  url: 'path/to/file',
  type: 'application/vnd.android.package-archive'
};

this.webIntent.startActivity(options).then(onSuccess, onError);

Instance Members

ACTION_SEND

Convenience constant for actions

ACTION_VIEW

Convenience constant for actions

EXTRA_TEXT

Convenience constant for extras

EXTRA_SUBJECT

Convenience constant for extras

EXTRA_STREAM

Convenience constant for extras

EXTRA_EMAIL

Convenience constant for extras

ACTION_CALL

Convenience constant for actions

ACTION_SENDTO

Convenience constant for actions

ACTION_GET_CONTENT

Convenience constant for actions

ACTION_PICK

Convenience constant for actions

ACTION_INSTALL_PACKAGE

Convenience constant for actions

ACTION_UNINSTALL_PACKAGE

Convenience constant for actions

startActivity(options)

Launches an Android intent

Param Type Details
options IntentOptions

Returns: Promise<any>

startActivityForResult(options)

Starts a new activity and return the result to the application

Param Type Details
options IntentOptions

Returns: Promise<any>

hasExtra(extra)

Checks if this app was invoked with specified extra

Param Type Details
extra string

Returns: Promise<any>

getExtra(extra)

Gets the extra that this app was invoked with

Param Type Details
extra string

Returns: Promise<any>

getUri()

Gets the Uri the app was invoked with

Returns: Promise<any>

onIntent()

Returns the content of the intent used whenever the application activity is launched

Returns: Observable<Intent>

sendBroadcast(options)

Sends a custom intent passing optional extras

Param Type Details
options IntentOptions

Returns: Promise<any>

startService(options)

Request that a given application service be started

Param Type Details
options IntentOptions

Returns: Promise<any>

registerBroadcastReceiver(filters)

Registers a broadcast receiver for the specified filters

Param Type Details
filters RegisterBroadcastReceiverOptions

Returns: Observable<any>

unregisterBroadcastReceiver()

Unregisters a broadcast receiver

getIntent()

Returns: Promise<Intent>

sendResult()

Send a result back to the Intent that started this Activity. The data can be passed using ‘extras’.

Returns: Promise<any>

IntentOptions

Param Type Details
requestCode number (optional)
type string (optional)
package string (optional)
url string (optional)
extras object (optional)
action string (optional)
component { package: string; class: string; } (optional)
flags number[] (optional)

API

Native

General