or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

analytics-monetization.mdcamera-media.mddevice-sensors.mddevice-system.mdindex.mdinput-hardware.mdlocation-maps.mdnetwork-communication.mdnotifications-ui.mdsecurity-auth.mdsocial-sharing.mdstorage-files.md
tile.json

tessl/npm-ionic-native

Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/ionic-native@2.9.x

To install, run

npx @tessl/cli install tessl/npm-ionic-native@2.9.0

index.mddocs/

Ionic Native

Ionic Native provides a comprehensive collection of TypeScript wrappers for Cordova plugins, enabling native mobile functionality in Ionic, Cordova, and web view applications. It standardizes native functionality access through Promise and Observable interfaces while maintaining compatibility with both Angular 1 and Angular 2+ applications.

Package Information

  • Package Name: ionic-native
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install ionic-native
  • Dependencies: RxJS 5.0.1

Core Imports

import { Camera, Device, Geolocation } from 'ionic-native';

For CommonJS:

const { Camera, Device, Geolocation } = require('ionic-native');

Browser global access:

// Available as window.IonicNative after including the bundle
window.IonicNative.Camera.getPicture(options);

Basic Usage

import { Camera, CameraOptions } from 'ionic-native';

// Configure camera options
const options: CameraOptions = {
  quality: 100,
  destinationType: Camera.DestinationType.FILE_URI,
  sourceType: Camera.PictureSourceType.CAMERA,
  encodingType: Camera.EncodingType.JPEG,
  targetWidth: 300,
  targetHeight: 300
};

// Take a picture
Camera.getPicture(options).then((imageData) => {
  // imageData is either a base64 encoded string or a file URI
  let base64Image = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
  // Handle error
});

Architecture

Ionic Native is built around several key architectural patterns:

  • Plugin Wrapper Pattern: All plugins extend from base plugin infrastructure with TypeScript decorators
  • Promise-based API: Most async operations return native Promises with Angular $q integration
  • Observable Support: Event-based operations use RxJS Observables for reactive programming
  • Static Method Pattern: Primary API surface uses static methods on plugin classes
  • Runtime Checking: Automatic plugin availability and Cordova environment validation
  • Cross-platform: Unified API across iOS, Android, Windows, and Browser platforms

Capabilities

Device & System Information

Core device information and system capabilities for identifying device characteristics and platform details.

class Device {
  static cordova: string;
  static model: string;
  static platform: string;
  static uuid: string;
  static version: string;
  static manufacturer: string;
  static isVirtual: boolean;
  static serial: string;
}

class AppVersion {
  static getAppName(): Promise<string>;
  static getPackageName(): Promise<string>;
  static getVersionCode(): Promise<string | number>;
  static getVersionNumber(): Promise<string>;
}

Device & System

Camera & Media Capture

Comprehensive camera functionality, media capture, and photo/video management with full configuration options.

interface CameraOptions {
  quality?: number;
  destinationType?: number;
  sourceType?: number;
  allowEdit?: boolean;
  encodingType?: number;
  targetWidth?: number;
  targetHeight?: number;
  mediaType?: number;
  correctOrientation?: boolean;
  saveToPhotoAlbum?: boolean;
  cameraDirection?: number;
  popoverOptions?: CameraPopoverOptions;
}

class Camera {
  static getPicture(options?: CameraOptions): Promise<any>;
  static cleanup(): Promise<any>;
  static DestinationType: {
    DATA_URL: 0;
    FILE_URI: 1;
    NATIVE_URI: 2;
  };
  static EncodingType: {
    JPEG: 0;
    PNG: 1;
  };
}

Camera & Media

Storage & File Management

File system operations, database access, and secure storage solutions for mobile app data persistence.

class File {
  static applicationDirectory: string;
  static dataDirectory: string;
  static cacheDirectory: string;
  static externalDataDirectory: string;
  static createFile(path: string, fileName: string, replace: boolean): Promise<FileEntry>;
  static writeFile(path: string, fileName: string, text: string | Blob | ArrayBuffer, options: IWriteOptions): Promise<any>;
  static readAsText(path: string, file: string): Promise<string>;
  static removeFile(path: string, fileName: string): Promise<RemoveResult>;
}

class SQLite {
  static create(config: any): SQLiteObject;
}

Storage & Files

Network & Communication

HTTP requests, network status monitoring, and in-app browser functionality for connected applications.

interface HTTPResponse {
  status: number;
  data?: any;
  headers: any;
  url: string;
}

class HTTP {
  static get(url: string, parameters: any, headers: any): Promise<HTTPResponse>;
  static post(url: string, body: any, headers: any): Promise<HTTPResponse>;
  static put(url: string, body: any, headers: any): Promise<HTTPResponse>;
  static delete(url: string, parameters: any, headers: any): Promise<HTTPResponse>;
}

class Network {
  static type: string;
  static onConnect(): Observable<any>;
  static onDisconnect(): Observable<any>;
}

Network & Communication

Location & Maps

Geolocation services, background location tracking, and geofencing capabilities for location-aware applications.

interface GeolocationOptions {
  enableHighAccuracy?: boolean;
  timeout?: number;
  maximumAge?: number;
}

interface Geoposition {
  coords: Coordinates;
  timestamp: number;
}

class Geolocation {
  static getCurrentPosition(options?: GeolocationOptions): Promise<Geoposition>;
  static watchPosition(options?: GeolocationOptions): Observable<Geoposition>;
}

Location & Maps

Notifications & UI

Push notifications, local notifications, dialogs, and UI interaction components for user engagement.

interface ILocalNotification {
  id?: number;
  title?: string;
  text?: string;
  every?: string;
  at?: Date;
  data?: any;
}

class LocalNotifications {
  static schedule(options?: ILocalNotification | ILocalNotification[]): void;
  static clear(notificationId: number): Promise<boolean>;
  static on(eventName: string): Observable<any>;
}

class Toast {
  static show(message: string, duration: string, position: string): Promise<any>;
  static showShortTop(message: string): Promise<any>;
}

Notifications & UI

Device Sensors

Access to device sensors including accelerometer, gyroscope, compass, battery status, and vibration.

interface Acceleration {
  x: number;
  y: number;
  z: number;
  timestamp: number;
}

class DeviceMotion {
  static getCurrentAcceleration(): Promise<Acceleration>;
  static watchAcceleration(options?: AccelerometerOptions): Observable<Acceleration>;
}

class Vibration {
  static vibrate(time: number | number[]): void;
}

Device Sensors

Social & Sharing

Social media integration, content sharing, and authentication for Facebook, Google+, and Twitter platforms.

class SocialSharing {
  static share(message?: string, subject?: string, file?: string | string[], url?: string): Promise<any>;
  static shareViaEmail(message: string, subject: string, to: string[], cc?: string[], bcc?: string[], files?: string | string[]): Promise<any>;
  static shareViaTwitter(message: string, image?: string, url?: string): Promise<any>;
}

interface FacebookLoginResponse {
  status: string;
  authResponse: {
    userID: string;
    accessToken: string;
  };
}

class Facebook {
  static login(permissions: string[]): Promise<FacebookLoginResponse>;
}

Social & Sharing

Security & Authentication

Biometric authentication, secure storage, and device security features for protecting user data.

class TouchID {
  static isAvailable(): Promise<string>;
  static verifyFingerprint(message: string): Promise<any>;
}

interface FingerprintOptions {
  clientId: string;
  clientSecret: string;
  disableBackup?: boolean;
}

class FingerprintAIO {
  static isAvailable(): Promise<any>;
  static show(options: FingerprintOptions): Promise<any>;
}

Security & Authentication

Input & Hardware

Barcode scanning, NFC communication, keyboard management, and hardware interaction capabilities.

interface BarcodeScannerOptions {
  preferFrontCamera?: boolean;
  showFlipCameraButton?: boolean;
  showTorchButton?: boolean;
  torchOn?: boolean;
  prompt?: string;
  resultDisplayDuration?: number;
  formats?: string;
  orientation?: string;
  disableAnimations?: boolean;
  disableSuccessBeep?: boolean;
}

interface BarcodeScanResult {
  text: string;
  format: string;
  cancelled: boolean;
}

class BarcodeScanner {
  static scan(options?: BarcodeScannerOptions): Promise<BarcodeScanResult>;
}

Input & Hardware

Analytics & Monetization

App analytics, advertising integration, and monetization features for tracking user behavior and revenue generation.

interface AdMobOptions {
  bannerId?: string;
  interstitialId?: string;
  rewardVideoId?: string;
  isTesting?: boolean;
  autoShow?: boolean;
}

class AdMob {
  static createBanner(adIdOrOptions: string | AdMobOptions): Promise<any>;
  static showInterstitial(): Promise<any>;
}

class GoogleAnalytics {
  static startTrackerWithId(id: string): Promise<any>;
  static trackView(title: string): Promise<any>;
  static trackEvent(category: string, action: string, label?: string, value?: number): Promise<any>;
}

Analytics & Monetization

Core Infrastructure

Plugin Decorator System

interface PluginConfig {
  pluginName: string;
  plugin: string;
  pluginRef: string;
  repo: string;
  install?: string;
  platforms?: string[];
}

interface CordovaOptions {
  sync?: boolean;
  observable?: boolean;
  callbackOrder?: 'reverse';
  callbackStyle?: 'node' | 'object';
  successIndex?: number;
  errorIndex?: number;
  platforms?: string[];
}

// TypeScript decorators for plugin method wrapping
function Plugin(config: PluginConfig): ClassDecorator;
function Cordova(opts?: CordovaOptions): MethodDecorator;
function CordovaInstance(opts?: any): MethodDecorator;
function CordovaProperty(target: any, key: string): void;

Types

// Core utility types used across plugins
interface RemoveResult {
  success: boolean;
  fileRemoved: Entry;
}

interface Entry {
  isFile: boolean;
  isDirectory: boolean;
  name: string;
  fullPath: string;
}

interface FileEntry extends Entry {
  file(successCallback: (file: File) => void, errorCallback?: (error: FileError) => void): void;
}

interface DirectoryEntry extends Entry {
  createReader(): DirectoryReader;
  getFile(path: string, options?: Flags, successCallback?: (entry: FileEntry) => void, errorCallback?: (error: FileError) => void): void;
  getDirectory(path: string, options?: Flags, successCallback?: (entry: DirectoryEntry) => void, errorCallback?: (error: FileError) => void): void;
}

// Promise/Observable type patterns
type CordovaPromise<T> = Promise<T>;
type CordovaObservable<T> = Observable<T>;