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
    
  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

startActivity(options)

Launches an Android intent

Param Type Details
options Object

{ action: any, url: string, type?: string }

Returns: Promise<any>

startActivityForResult(options)

Starts a new activity and return the result to the application

Param Type Details
options Object

{ action: any, url: string, type?: string }

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<string>

sendBroadcast(options)

Sends a custom intent passing optional extras

Param Type Details
options Object

{ action: string, extras?: { option: boolean } }

Returns: Promise<any>

startService(options)

Request that a given application service be started

Param Type Details
options Object

{ action: string, extras?: { option: boolean } }

Returns: Promise<any>

registerBroadcastReceiver(filters)

Registers a broadcast receiver for the specified filters

Param Type Details
filters any

unregisterBroadcastReceiver()

Unregisters a broadcast receiver

getIntent()

Returns: Promise<any>

API

Native

General