ionic-native
- Version 2.9.0
- Published
- 1 dependency
- MIT license
Install
npm i ionic-native
yarn add ionic-native
pnpm add ionic-native
Overview
Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support
Index
Variables
Functions
Classes
Appodeal
- AD_TYPES
- cache()
- confirm()
- disableLocationPermissionCheck()
- disableNetwork()
- disableNetworkType()
- disableWriteExternalStoragePermissionCheck()
- enableBannerCallbacks()
- enableInterstitialCallbacks()
- enableNonSkippableVideoCallbacks()
- enableRewardedVideoCallbacks()
- enableSkippableVideoCallbacks()
- getVersion()
- hide()
- initialize()
- isInitialized()
- isLoaded()
- isPrecache()
- onBannerClicked()
- onBannerFailedToLoad()
- onBannerLoaded()
- onBannerShown()
- onInterstitialClicked()
- onInterstitialClosed()
- onInterstitialFailedToLoad()
- onInterstitialLoaded()
- onInterstitialShown()
- onNonSkippableVideoClosed()
- onNonSkippableVideoFailedToLoad()
- onNonSkippableVideoFinished()
- onNonSkippableVideoLoaded()
- onNonSkippableVideoShown()
- onRewardedVideoClosed()
- onRewardedVideoFailedToLoad()
- onRewardedVideoFinished()
- onRewardedVideoLoaded()
- onRewardedVideoShown()
- onSkippableVideoClosed()
- onSkippableVideoFailedToLoad()
- onSkippableVideoFinished()
- onSkippableVideoLoaded()
- onSkippableVideoShown()
- resetUUID()
- set728x90Banners()
- setAge()
- setAlcohol()
- setAutoCache()
- setBannerAnimation()
- setBannerBackground()
- setBirthday()
- setCustomBooleanRule()
- setCustomDoubleRule()
- setCustomIntegerRule()
- setCustomStringRule()
- setEmail()
- setGender()
- setInterests()
- setLogging()
- setOccupation()
- setOnLoadedTriggerBoth()
- setRelation()
- setSmartBanners()
- setSmoking()
- setTesting()
- setUserId()
- show()
- showWithPlacement()
BackgroundGeolocation
- Accuracy
- changePace()
- configure()
- deleteAllLocations()
- deleteLocation()
- finish()
- getLocations()
- getLogEntries()
- getStationaryLocation()
- getValidLocations()
- isLocationEnabled()
- LocationProvider
- Mode
- onStationary()
- setConfig()
- showAppSettings()
- showLocationSettings()
- start()
- stop()
- stopWatchingLocationMode()
- switchMode()
- watchLocationMode()
Calendar
- createCalendar()
- createEvent()
- createEventInteractively()
- createEventInteractivelyWithOptions()
- createEventWithOptions()
- deleteCalendar()
- deleteEvent()
- deleteEventFromNamedCalendar()
- findAllEventsInNamedCalendar()
- findEvent()
- findEventWithOptions()
- getCalendarOptions()
- hasReadPermission()
- hasReadWritePermission()
- hasWritePermission()
- listCalendars()
- listEventsInRange()
- modifyEvent()
- modifyEventWithOptions()
- openCalendar()
- requestReadPermission()
- requestReadWritePermission()
- requestWritePermission()
Diagnostic
- bluetoothState
- getBackgroundRefreshStatus()
- getBluetoothState()
- getCalendarAuthorizationStatus()
- getCameraAuthorizationStatus()
- getCameraRollAuthorizationStatus()
- getContactsAuthorizationStatus()
- getExternalSdCardDetails()
- getExternalStorageAuthorizationStatus()
- getLocationAuthorizationStatus()
- getLocationMode()
- getMicrophoneAuthorizationStatus()
- getPermissionAuthorizationStatus()
- getPermissionsAuthorizationStatus()
- getRemindersAuthorizationStatus()
- getRemoteNotificationTypes()
- hasBluetoothLEPeripheralSupport()
- hasBluetoothLESupport()
- hasBluetoothSupport()
- isBackgroundRefreshAuthorized()
- isBluetoothAvailable()
- isBluetoothEnabled()
- isCalendarAuthorized()
- isCameraAuthorized()
- isCameraAvailable()
- isCameraPresent()
- isCameraRollAuthorized()
- isContactsAuthorized()
- isExternalStorageAuthorized()
- isGpsLocationAvailable()
- isGpsLocationEnabled()
- isLocationAuthorized()
- isLocationAvailable()
- isLocationEnabled()
- isMicrophoneAuthorized()
- isMotionAvailable()
- isMotionRequestOutcomeAvailable()
- isNetworkLocationAvailable()
- isNetworkLocationEnabled()
- isNFCAvailable()
- isNFCEnabled()
- isNFCPresent()
- isRegisteredForRemoteNotifications()
- isRemindersAuthorized()
- isRemoteNotificationsEnabled()
- isRequestingPermission()
- isWifiAvailable()
- isWifiEnabled()
- locationAuthorizationMode
- locationMode
- NFCState
- permission
- permissionGroups
- permissionStatus
- registerBluetoothStateChangeHandler()
- registerLocationStateChangeHandler()
- registerNFCStateChangeHandler()
- registerPermissionRequestCompleteHandler()
- requestAndCheckMotionAuthorization()
- requestBluetoothAuthorization()
- requestCalendarAuthorization()
- requestCameraAuthorization()
- requestCameraRollAuthorization()
- requestContactsAuthorization()
- requestExternalStorageAuthorization()
- requestLocationAuthorization()
- requestMicrophoneAuthorization()
- requestRemindersAuthorization()
- requestRuntimePermission()
- requestRuntimePermissions()
- setBluetoothState()
- setWifiState()
- switchToBluetoothSettings()
- switchToLocationSettings()
- switchToMobileDataSettings()
- switchToNFCSettings()
- switchToSettings()
- switchToWifiSettings()
- switchToWirelessSettings()
EstimoteBeacons
- authorizationStatus()
- BeaconColorBlueberryPie
- BeaconColorCandyFloss
- BeaconColorIcyMarshmallow
- BeaconColorLemonTart
- BeaconColorLiquoriceSwirl
- BeaconColorMintCocktail
- BeaconColorSweetBeetroot
- BeaconColorTransparent
- BeaconColorUnknown
- BeaconColorVanillaJello
- BeaconColorWhite
- connectToBeacon()
- disconnectConnectedBeacon()
- enableAnalytics()
- isAnalyticsEnabled()
- isAuthorized()
- ProximityFar
- ProximityImmediate
- ProximityNear
- ProximityUnknown
- RegionStateInside
- RegionStateOutside
- RegionStateUnknown
- requestAlwaysAuthorization()
- requestWhenInUseAuthorization()
- setupAppIDAndAppToken()
- startAdvertisingAsBeacon()
- startEstimoteBeaconDiscovery()
- startMonitoringForRegion()
- startRangingBeaconsInRegion()
- startRangingSecureBeaconsInRegion()
- startSecureMonitoringForRegion()
- stopAdvertisingAsBeacon()
- stopEstimoteBeaconDiscovery()
- stopMonitoringForRegion()
- stopRangingBeaconsInRegion()
- stopRangingSecureBeaconsInRegion()
- stopSecureMonitoringForRegion()
- writeConnectedMajor()
- writeConnectedMinor()
- writeConnectedProximityUUID()
File
- applicationDirectory
- applicationStorageDirectory
- cacheDirectory
- checkDir()
- checkFile()
- copyDir()
- copyFile()
- cordovaFileError
- createDir()
- createFile()
- dataDirectory
- documentsDirectory
- externalApplicationStorageDirectory
- externalCacheDirectory
- externalDataDirectory
- externalRootDirectory
- getDirectory()
- getFile()
- getFreeDiskSpace()
- listDir()
- moveDir()
- moveFile()
- readAsArrayBuffer()
- readAsBinaryString()
- readAsDataURL()
- readAsText()
- removeDir()
- removeFile()
- removeRecursively()
- resolveDirectoryUrl()
- resolveLocalFilesystemUrl()
- sharedDirectory
- syncedDataDirectory
- tempDirectory
- writeExistingFile()
- writeFile()
GoogleMap
- addCircle()
- addEventListener()
- addGroundOverlay()
- addKmlOverlay()
- addListenerOnce()
- addMarker()
- addPolygon()
- addPolyline()
- addTileOverlay()
- animateCamera()
- clear()
- closeDialog()
- empty()
- fromLatLngToPoint()
- fromPointToLatLng()
- get()
- getCameraPosition()
- getLicenseInfo()
- getMyLocation()
- getVisibleRegion()
- isAvailable()
- moveCamera()
- on()
- one()
- panBy()
- refreshLayout()
- remove()
- set()
- setAllGesturesEnabled()
- setBackgroundColor()
- setCenter()
- setClickable()
- setCompassEnabled()
- setDebuggable()
- setDiv()
- setIndoorEnabled()
- setMapTypeId()
- setMyLocationEnabled()
- setOptions()
- setPadding()
- setTilt()
- setTrafficEnabled()
- setVisible()
- setZoom()
- showDialog()
- toDataURL()
GoogleMapsMarker
- addEventListener()
- addListenerOnce()
- empty()
- get()
- getHashCode()
- getMap()
- getOpacity()
- getPosition()
- getRotation()
- getSnippet()
- getTitle()
- hideInfoWindow()
- isDraggable()
- isVisible()
- on()
- one()
- remove()
- set()
- setAnimation()
- setDraggable()
- setFlat()
- setIcon()
- setIconAnchor()
- setInfoWindowAnchor()
- setOpacity()
- setPosition()
- setRotation()
- setSnippet()
- setTitle()
- setVisible()
- setZIndex()
- showInfoWindow()
Hotspot
- addWifiNetwork()
- configureHotspot()
- connectToWifi()
- connectToWifiAuthEncrypt()
- createHotspot()
- getAllHotspotDevices()
- getConnectionInfo()
- getMacAddressOfHost()
- getNetConfig()
- isAvailable()
- isConnectedToInternet()
- isConnectedToInternetViaWifi()
- isDnsLive()
- isHotspotEnabled()
- isPortLive()
- isRooted()
- isWifiDirectSupported()
- isWifiOn()
- isWifiSupported()
- pingHost()
- removeWifiNetwork()
- scanWifi()
- scanWifiByLevel()
- startHotspot()
- startWifiPeriodicallyScan()
- stopHotspot()
- stopWifiPeriodicallyScan()
- toggleWifi()
IBeacon
- appendToDeviceLog()
- BeaconRegion()
- Delegate()
- disableBluetooth()
- disableDebugLogs()
- disableDebugNotifications()
- enableBluetooth()
- enableDebugLogs()
- enableDebugNotifications()
- getAuthorizationStatus()
- getDelegate()
- getMonitoredRegions()
- getRangedRegions()
- isAdvertising()
- isAdvertisingAvailable()
- isBluetoothEnabled()
- isMonitoringAvailableForClass()
- isRangingAvailable()
- onDomDelegateReady()
- requestAlwaysAuthorization()
- requestStateForRegion()
- requestWhenInUseAuthorization()
- setDelegate()
- startAdvertising()
- startMonitoringForRegion()
- startRangingBeaconsInRegion()
- stopAdvertising()
- stopMonitoringForRegion()
- stopRangingBeaconsInRegion()
LocationAccuracy
- canRequest()
- ERROR_ALREADY_REQUESTING
- ERROR_CANNOT_CHANGE_ACCURACY
- ERROR_EXCEPTION
- ERROR_GOOGLE_API_CONNECTION_FAILED
- ERROR_INVALID_ACCURACY
- ERROR_INVALID_ACTION
- ERROR_USER_DISAGREED
- isRequesting()
- request()
- REQUEST_PRIORITY_BALANCED_POWER_ACCURACY
- REQUEST_PRIORITY_HIGH_ACCURACY
- REQUEST_PRIORITY_LOW_POWER
- REQUEST_PRIORITY_NO_POWER
- SUCCESS_SETTINGS_SATISFIED
- SUCCESS_USER_AGREED
OneSignal
- deleteTag()
- deleteTags()
- enableSound()
- enableVibrate()
- endInit()
- getIds()
- getTags()
- handleNotificationOpened()
- handleNotificationReceived()
- inFocusDisplaying()
- iOSSettings()
- OSInFocusDisplayOption
- postNotification()
- promptLocation()
- registerForPushNotifications()
- sendTag()
- sendTags()
- setLogLevel()
- setSubscription()
- startInit()
- syncHashedEmail()
Interfaces
BackgroundGeolocationConfig
- activitiesInterval
- activityType
- debug
- desiredAccuracy
- distanceFilter
- fastestInterval
- httpHeaders
- interval
- locationProvider
- maxLocations
- notificationIconColor
- notificationIconLarge
- notificationIconSmall
- notificationText
- notificationTitle
- pauseLocationUpdates
- saveBatteryOnBackground
- startForeground
- startOnBoot
- stationaryRadius
- stopOnStillActivity
- stopOnTerminate
- syncThreshold
- syncUrl
- url
InAppBrowserOptions
- allowInlineMediaPlayback
- clearcache
- clearsessioncache
- closebuttoncaption
- disallowoverscroll
- enableViewportScale
- fullscreen
- hardwareback
- hidden
- keyboardDisplayRequiresUserAction
- location
- mediaPlaybackRequiresUserAction
- presentationstyle
- shouldPauseOnSuspend
- suppressesIncrementalRendering
- toolbar
- toolbarposition
- transitionstyle
- zoom
OSNotification
- adm_big_picture
- adm_group
- adm_group_message
- adm_large_icon
- adm_small_icon
- adm_sound
- amazon_background_data
- android_accent_color
- android_group
- android_group_message
- android_led_color
- android_sound
- android_visibility
- androidNotificationId
- app_id
- app_ids
- big_picture
- buttons
- chrome_big_picture
- chrome_icon
- chrome_web_icon
- content_available
- contents
- data
- delayed_option
- delivery_time_of_day
- displayType
- excluded_segments
- firefox_icon
- groupedNotifications
- headings
- include_amazon_reg_ids
- include_android_reg_ids
- include_chrome_reg_ids
- include_chrome_web_reg_ids
- include_ios_tokens
- include_player_ids
- include_wp_uris
- include_wp_wns_uris
- included_segments
- ios_badgeCount
- ios_badgeType
- ios_category
- ios_sound
- isAdm
- isAndroid
- isAnyWeb
- isAppInFocus
- isChrome
- isChromeWeb
- isIos
- isSafari
- isWP
- isWP_WNS
- large_icon
- payload
- priority
- send_after
- shown
- small_icon
- tags
- template_id
- ttl
- url
- wp_sound
- wp_wns_sound
ThemeableBrowserOptions
- allowInlineMediaPlayback
- backButton
- backButtonCanClose
- clearcache
- clearsessioncache
- closeButton
- closebuttoncaption
- customButtons
- disableAnimation
- disallowoverscroll
- enableViewportScale
- forwardButton
- fullscreen
- hardwareback
- hidden
- keyboardDisplayRequiresUserAction
- location
- mediaPlaybackRequiresUserAction
- menu
- presentationstyle
- shouldPauseOnSuspsend
- statusbar
- suppressesIncrementalRendering
- title
- toolbar
- toolbarposition
- transitionstyle
- zoom
Enums
Type Aliases
Variables
variable ContactError
var ContactError: { new (code: number): IContactError; UNKNOWN_ERROR: number; INVALID_ARGUMENT_ERROR: number; TIMEOUT_ERROR: number; PENDING_OPERATION_ERROR: number; IO_ERROR: number; NOT_SUPPORTED_ERROR: number; PERMISSION_DENIED_ERROR: number;};
variable FileError
var FileError: { new (code: number): FileError; NOT_FOUND_ERR: number; SECURITY_ERR: number; ABORT_ERR: number; NOT_READABLE_ERR: number; ENCODING_ERR: number; NO_MODIFICATION_ALLOWED_ERR: number; INVALID_STATE_ERR: number; SYNTAX_ERR: number; INVALID_MODIFICATION_ERR: number; QUOTA_EXCEEDED_ERR: number; TYPE_MISMATCH_ERR: number; PATH_EXISTS_ERR: number;};
variable FileReader
var FileReader: { new (): FileReader; EMPTY: number; LOADING: number; DONE: number };
variable FileWriter
var FileWriter: { INIT: number; WRITING: number; DONE: number };
variable GoogleMapsAnimation
const GoogleMapsAnimation: { BOUNCE: string; DROP: string };
variable GoogleMapsEvent
const GoogleMapsEvent: { MAP_CLICK: string; MAP_LONG_CLICK: string; MY_LOCATION_CHANGE: string; MY_LOCATION_BUTTON_CLICK: string; INDOOR_BUILDING_FOCUSED: string; INDOOR_LEVEL_ACTIVATED: string; CAMERA_CHANGE: string; CAMERA_IDLE: string; MAP_READY: string; MAP_LOADED: string; MAP_WILL_MOVE: string; MAP_CLOSE: string; MARKER_CLICK: string; OVERLAY_CLICK: string; INFO_CLICK: string; MARKER_DRAG: string; MARKER_DRAG_START: string; MARKER_DRAG_END: string;};
You can listen to these events where appropriate
variable GoogleMapsMapTypeId
const GoogleMapsMapTypeId: { HYBRID: string; NONE: string; NORMAL: string; ROADMAP: string; SATELLITE: string; TERAIN: string;};
Functions
function Cordova
Cordova: ( opts?: CordovaOptions) => ( target: Object, methodName: string, descriptor: TypedPropertyDescriptor<any>) => { value: (...args: any[]) => any };
Wrap a stub function in a call to a Cordova plugin, checking if both Cordova and the required plugin are installed.
function CordovaFiniteObservable
CordovaFiniteObservable: ( opts?: CordovaFiniteObservableOptions) => ( target: Object, methodName: string, descriptor: TypedPropertyDescriptor<any>) => { value: (...args: any[]) => Observable<any> };
Wraps method that returns an observable that can be completed. Provided opts.resultFinalPredicate dictates when the observable completes.
function CordovaFunctionOverride
CordovaFunctionOverride: ( opts?: any) => ( target: Object, methodName: string, descriptor: TypedPropertyDescriptor<any>) => { value: (...args: any[]) => Observable<any> };
Wrap a stub function in a call to a Cordova plugin, checking if both Cordova and the required plugin are installed.
function CordovaInstance
CordovaInstance: ( opts?: any) => (target: Object, methodName: string) => { value: (...args: any[]) => any };
Wrap an instance method
function CordovaProperty
CordovaProperty: (target: any, key: string) => void;
Before calling the original method, ensure Cordova and the plugin are installed.
function cordovaWarn
cordovaWarn: (pluginName: string, method: string) => void;
Parameter pluginName
Parameter method
function getPlugin
getPlugin: (pluginRef: string) => any;
Parameter pluginRef
Returns
{null|*}
function getPromise
getPromise: (cb: any) => any;
function InstanceProperty
InstanceProperty: (target: any, key: string) => void;
Parameter target
Parameter key
function Plugin
Plugin: (config: PluginConfig) => (cls: any) => any;
Class decorator specifying Plugin metadata. Required for all plugins.
@Plugin({pluginName: 'MyPlugin',plugin: 'cordova-plugin-myplugin',pluginRef: 'window.myplugin'})export class MyPlugin {// Plugin wrappers, properties, and functions go here ...}
function pluginWarn
pluginWarn: (pluginObj: any, method?: string) => void;
Parameter pluginObj
Parameter method
function wrap
wrap: ( pluginObj: any, methodName: string, opts?: CordovaOptions) => (...args: any[]) => any;
Parameter pluginObj
Parameter methodName
Parameter opts
Returns
{function(...[any]): (undefined|*|Observable|*|*)}
Classes
class ActionSheet
class ActionSheet {}
Action Sheet The ActionSheet plugin shows a native list of options the user can choose from.
Requires Cordova plugin:
cordova-plugin-actionsheet
. For more info, please see the [ActionSheet plugin docs](https://github.com/EddyVerbruggen/cordova-plugin-actionsheet).import { ActionSheet } from 'ionic-native';let buttonLabels = ['Share via Facebook', 'Share via Twitter'];ActionSheet.show({'title': 'What do you want with this image?','buttonLabels': buttonLabels,'addCancelButtonWithLabel': 'Cancel','addDestructiveButtonWithLabel' : 'Delete'}).then((buttonIndex: number) => {console.log('Button pressed: ' + buttonIndex);});ActionSheetOptions
method hide
static hide: (options?: any) => Promise<any>;
Progamtically hide the native ActionSheet
Returns
{Promise} Returns a Promise that resolves when the actionsheet is closed
method show
static show: (options?: ActionSheetOptions) => Promise<any>;
Show a native ActionSheet component. See below for options.
Parameter options
Options See table below
Returns
{Promise} Returns a Promise that resolves with the index of the button pressed (1 based, so 1, 2, 3, etc.)
class AdMob
class AdMob {}
AdMob Plugin for Google Ads, including AdMob / DFP (doubleclick for publisher) and mediations to other Ad networks.
import { AdMob } from 'ionic-native';ionViewDidLoad() {AdMob.onAdDismiss().subscribe(() => { console.log('User dismissed ad'); });}onClick() {AdMob.prepareInterstitial('YOUR_ADID').then(() => { AdMob.showInterstitial(); });}AdMobOptions AdMobAdExtras
property AD_POSITION
static AD_POSITION: { NO_CHANGE: number; TOP_LEFT: number; TOP_CENTER: number; TOP_RIGHT: number; LEFT: number; CENTER: number; RIGHT: number; BOTTOM_LEFT: number; BOTTOM_CENTER: number; BOTTOM_RIGHT: number; POS_XY: number;};
method createBanner
static createBanner: (adIdOrOptions: string | AdMobOptions) => Promise<any>;
Create a banner
Parameter adIdOrOptions
Ad ID or Options
Returns
{Promise} Returns a Promise that resolves when the banner is created
method getAdSettings
static getAdSettings: () => Promise<any>;
Get user ad settings
Returns
{Promise} Returns a promise that resolves with the ad settings
method hideBanner
static hideBanner: () => void;
Hide the banner, remove it from screen, but can show it later
method onAdDismiss
static onAdDismiss: () => Observable<any>;
Triggered when dismiss the Ad and back to your App
Returns
{Observable}
method onAdFailLoad
static onAdFailLoad: () => Observable<any>;
Triggered when failed to receive Ad
Returns
{Observable}
method onAdLeaveApp
static onAdLeaveApp: () => Observable<any>;
Triggered when user click the Ad, and will jump out of your App
Returns
{Observable}
method onAdLoaded
static onAdLoaded: () => Observable<any>;
Triggered when Ad received
Returns
{Observable}
method onAdPresent
static onAdPresent: () => Observable<any>;
Triggered when Ad will be showed on screen
Returns
{Observable}
method prepareInterstitial
static prepareInterstitial: ( adIdOrOptions: string | AdMobOptions) => Promise<any>;
Prepare interstitial banner
Parameter adIdOrOptions
Ad ID or Options
Returns
{Promise} Returns a Promise that resolves when interstitial is prepared
method prepareRewardVideoAd
static prepareRewardVideoAd: ( adIdOrOptions: string | AdMobOptions) => Promise<any>;
Prepare a reward video ad
Parameter adIdOrOptions
Ad ID or Options
Returns
{Promise} Returns a Promise that resolves when the ad is prepared
method removeBanner
static removeBanner: () => void;
Destroy the banner, remove it from screen.
method setOptions
static setOptions: (options: AdMobOptions) => Promise<any>;
Sets the values for configuration and targeting
Parameter options
Options
Returns
{Promise} Returns a Promise that resolves when the options have been set
method showBanner
static showBanner: (position: number) => void;
Show banner at position
Parameter position
Position. Use
AdMob.AD_POSITION
to set values.
method showBannerAtXY
static showBannerAtXY: (x: number, y: number) => void;
Show banner at custom position
Parameter x
Offset from screen left.
Parameter y
Offset from screen top.
method showInterstitial
static showInterstitial: () => void;
Show interstitial ad when it's ready
method showRewardVideoAd
static showRewardVideoAd: () => void;
Show a reward video ad
class Alipay
class Alipay {}
Alipay This plugin is used for Alipay APP support. Integrated with the latest SDK.
Requires Cordova plugin:
cordova-alipay-base
. For more info, please see the [Alipay plugin docs](https://github.com/xueron/cordova-alipay-base).import { Alipay } from 'ionic-native';// Should get from server side with sign.let alipayOrder = {...};Alipay.pay(alipayOrder).then(result => {console.log(result); // Success}).catch(error => {console.log(error); // Failed});AlipayOrder
method pay
static pay: (order: AlipayOrder) => Promise<any>;
Open Alipay to perform App pay
Parameter order
alipay options
Returns
{Promise} Returns a Promise that resolves with the success return, or rejects with an error.
class AndroidFingerprintAuth
class AndroidFingerprintAuth {}
Android Fingerprint Auth This plugin will open a native dialog fragment prompting the user to authenticate using their fingerprint. If the device has a secure lockscreen (pattern, PIN, or password), the user may opt to authenticate using that method as a backup.
import { AndroidFingerprintAuth } from 'ionic-native';AndroidFingerprintAuth.isAvailable().then((result)=> {if(result.isAvailable){// it is availableAndroidFingerprintAuth.encrypt({ clientId: "myAppName", username: "myUsername", password: "myPassword" }).then(result => {if (result.withFingerprint) {console.log("Successfully encrypted credentials.");console.log("Encrypted credentials: " + result.token);} else if (result.withBackup) {console.log('Successfully authenticated with backup password!');} else console.log('Didn\'t authenticate!');}).catch(error => {if (error === "Cancelled") {console.log("Fingerprint authentication cancelled");} else console.error(error)});} else {// fingerprint auth isn't available}}).catch(error => console.error(error));AndroidFingerprintAuthOptions
method decrypt
static decrypt: ( options: AndroidFingerprintAuthOptions) => Promise<{ withFingerprint: boolean; withBackup: boolean; password: string;}>;
Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.
Parameter options
Options
Returns
{Promise}
method delete
static delete: (options: { clientId: string; username: string;}) => Promise<{ deleted: boolean }>;
Delete the cipher used for encryption and decryption by username
Returns
{Promise} Returns a Promise that resolves if the cipher was successfully deleted
method encrypt
static encrypt: ( options: AndroidFingerprintAuthOptions) => Promise<{ withFingerprint: boolean; withBackup: boolean; token: string }>;
Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.
Parameter options
Options
Returns
{Promise}
method isAvailable
static isAvailable: () => Promise<{ isAvailable: boolean }>;
Check if service is available
Returns
{Promise} Returns a Promise that resolves if fingerprint auth is available on the device
class AppAvailability
class AppAvailability {}
App Availability This plugin allows you to check if an app is installed on the user's device. It requires an URI Scheme (e.g. twitter://) on iOS or a Package Name (e.g com.twitter.android) on Android.
Requires Cordova plugin: cordova-plugin-appavailability. For more info, please see the [AppAvailability plugin docs](https://github.com/ohh2ahh/AppAvailability).
import { AppAvailability, Device } from 'ionic-native';let app;if (Device.platform === 'iOS') {app = 'twitter://';} else if (Device.platform === 'Android') {app = 'com.twitter.android';}AppAvailability.check(app).then((yes: string) => console.log(app + ' is available'),(no: string) => console.log(app + ' is NOT available'));
method check
static check: (app: string) => Promise<boolean>;
Checks if an app is available on device
Parameter app
Package name on android, or URI scheme on iOS
Returns
{Promise}
class Appodeal
class Appodeal {}
Appodeal Plugin to serve ads through native Appodeal SDKs
import { Appodeal } from 'ionic-native';let appKey = '<your app key>';Appodeal.initialize(appKey, Appodeal.AD_TYPES.REWARDED_VIDEO);Appodeal.show(Appodeal.AD_TYPES.REWARDED_VIDEO);
property AD_TYPES
static readonly AD_TYPES: { INTERSTITIAL: number; SKIPPABLE_VIDEO: number; BANNER: number; BANNER_BOTTOM: number; BANNER_TOP: number; REWARDED_VIDEO: number; NON_SKIPPABLE_VIDEO: number;};
method cache
static cache: (adType: number) => void;
forcefully cache an ad by type
Parameter adType
method confirm
static confirm: (adType: number) => void;
confirm use of ads of specified type
Parameter adType
method disableLocationPermissionCheck
static disableLocationPermissionCheck: () => void;
disable Location permissions for Appodeal SDK
method disableNetwork
static disableNetwork: (network?: string, adType?: number) => void;
Parameter network
Parameter adType
method disableNetworkType
static disableNetworkType: (network?: string, adType?: number) => void;
Parameter network
Parameter adType
method disableWriteExternalStoragePermissionCheck
static disableWriteExternalStoragePermissionCheck: () => void;
disable Storage permissions for Appodeal SDK
method enableBannerCallbacks
static enableBannerCallbacks: (enabled: boolean) => void;
enable event listeners
Parameter enabled
method enableInterstitialCallbacks
static enableInterstitialCallbacks: (enabled: boolean) => void;
enable event listeners
Parameter enabled
method enableNonSkippableVideoCallbacks
static enableNonSkippableVideoCallbacks: (enabled: boolean) => void;
enable event listeners
Parameter enabled
method enableRewardedVideoCallbacks
static enableRewardedVideoCallbacks: (enabled: boolean) => void;
enable event listeners
Parameter enabled
method enableSkippableVideoCallbacks
static enableSkippableVideoCallbacks: (enabled: boolean) => void;
enable event listeners
Parameter enabled
method getVersion
static getVersion: () => Promise<any>;
get version of Appdeal SDK
method hide
static hide: (adType: number) => void;
hide ad of specified type
Parameter adType
method initialize
static initialize: (appKey: string, adType: number) => void;
initialize Appodeal SDK
Parameter appKey
Parameter adType
method isInitialized
static isInitialized: () => Promise<any>;
check if SDK has been initialized
Returns
{Promise}
method isLoaded
static isLoaded: (adType: number) => Promise<any>;
check if ad of specified type has been loaded
Parameter adType
Returns
{Promise}
method isPrecache
static isPrecache: (adType: number) => Promise<any>;
check if ad of specified
Parameter adType
Returns
{Promise}
method onBannerClicked
static onBannerClicked: () => Observable<any>;
method onBannerFailedToLoad
static onBannerFailedToLoad: () => Observable<any>;
method onBannerLoaded
static onBannerLoaded: () => Observable<any>;
method onBannerShown
static onBannerShown: () => Observable<any>;
method onInterstitialClicked
static onInterstitialClicked: () => Observable<any>;
method onInterstitialClosed
static onInterstitialClosed: () => Observable<any>;
method onInterstitialFailedToLoad
static onInterstitialFailedToLoad: () => Observable<any>;
method onInterstitialLoaded
static onInterstitialLoaded: () => Observable<any>;
******************* event Observables * *******************
method onInterstitialShown
static onInterstitialShown: () => Observable<any>;
method onNonSkippableVideoClosed
static onNonSkippableVideoClosed: () => Observable<any>;
method onNonSkippableVideoFailedToLoad
static onNonSkippableVideoFailedToLoad: () => Observable<any>;
method onNonSkippableVideoFinished
static onNonSkippableVideoFinished: () => Observable<any>;
method onNonSkippableVideoLoaded
static onNonSkippableVideoLoaded: () => Observable<any>;
method onNonSkippableVideoShown
static onNonSkippableVideoShown: () => Observable<any>;
method onRewardedVideoClosed
static onRewardedVideoClosed: () => Observable<any>;
method onRewardedVideoFailedToLoad
static onRewardedVideoFailedToLoad: () => Observable<any>;
method onRewardedVideoFinished
static onRewardedVideoFinished: () => Observable<any>;
method onRewardedVideoLoaded
static onRewardedVideoLoaded: () => Observable<any>;
method onRewardedVideoShown
static onRewardedVideoShown: () => Observable<any>;
method onSkippableVideoClosed
static onSkippableVideoClosed: () => Observable<any>;
method onSkippableVideoFailedToLoad
static onSkippableVideoFailedToLoad: () => Observable<any>;
method onSkippableVideoFinished
static onSkippableVideoFinished: () => Observable<any>;
method onSkippableVideoLoaded
static onSkippableVideoLoaded: () => Observable<any>;
method onSkippableVideoShown
static onSkippableVideoShown: () => Observable<any>;
method resetUUID
static resetUUID: () => void;
reset device ID
method set728x90Banners
static set728x90Banners: (value: any) => void;
Parameter value
method setAge
static setAge: (age: any) => void;
et Age preference in Appodeal for current user
Parameter age
method setAlcohol
static setAlcohol: (alcohol: any) => void;
set Alcohol preference in Appodeal for current user
Parameter alcohol
method setAutoCache
static setAutoCache: (adType: number, autoCache: any) => void;
Parameter adType
Parameter autoCache
method setBannerAnimation
static setBannerAnimation: (enabled: boolean) => void;
enable or disable banner animations
Parameter enabled
method setBannerBackground
static setBannerBackground: (enabled: boolean) => void;
enable or disable banner backgrounds
Parameter enabled
method setBirthday
static setBirthday: (birthday: any) => void;
set Birthday preference in Appodeal for current user
Parameter birthday
method setCustomBooleanRule
static setCustomBooleanRule: (name: string, value: boolean) => void;
Parameter name
name of rule
Parameter value
method setCustomDoubleRule
static setCustomDoubleRule: (name: string, value: number) => void;
set rule with float value
Parameter name
Parameter value
method setCustomIntegerRule
static setCustomIntegerRule: (name: string, value: number) => void;
Parameter name
name of rule
Parameter value
method setCustomStringRule
static setCustomStringRule: (name: string, value: string) => void;
set rule with string value
Parameter name
name of rule
Parameter value
method setEmail
static setEmail: (email: any) => void;
set Email preference in Appodeal for current user
Parameter email
method setGender
static setGender: (gender: any) => void;
set Gender preference in Appodeal for current user
Parameter gender
method setInterests
static setInterests: (interests: any) => void;
set Interests preference in Appodeal for current user
Parameter interests
method setLogging
static setLogging: (logging: boolean) => void;
enable or disable logging
Parameter logging
method setOccupation
static setOccupation: (occupation: any) => void;
set Occupation preference in Appodeal for current user
Parameter occupation
method setOnLoadedTriggerBoth
static setOnLoadedTriggerBoth: (set: boolean) => void;
Parameter set
method setRelation
static setRelation: (relation: any) => void;
set Relation preference in Appodeal for current user
Parameter relation
method setSmartBanners
static setSmartBanners: (enabled: boolean) => void;
enable or disable Smart Banners
Parameter enabled
method setSmoking
static setSmoking: (smoking: any) => void;
set Smoking preference in Appodeal for current user
Parameter smoking
method setTesting
static setTesting: (testing: boolean) => void;
enable or disable testing mode
Parameter testing
method setUserId
static setUserId: (id: any) => void;
set ID preference in Appodeal for current user
Parameter id
method show
static show: (adType: number) => Promise<any>;
show ad of specified type
Parameter adType
Returns
{Promise}
method showWithPlacement
static showWithPlacement: (adType: number, placement: any) => Promise<any>;
show ad of specified type with placement options
Parameter adType
Parameter placement
Returns
{Promise}
class AppPreferences
class AppPreferences {}
AppPreferences This plugin allows you to read and write app preferences
import { AppPreferences } from 'ionic-native';AppPreferences.fetch('key').then((res) => { console.log(res); });
method clearAll
static clearAll: () => Promise<any>;
Clear preferences
{Promise} Returns a promise
method cloudSync
static cloudSync: () => Object;
Return cloud synchronized configuration context Currently supports Windows and iOS/macOS
Returns
{Object} Custom object, bound to that suite
method defaults
static defaults: () => Object;
Return default configuration context Currently supports Windows and iOS/macOS
Returns
{Object} Custom Object, bound to that suite
method fetch
static fetch: (dict: string, key?: string) => Promise<any>;
Get a preference value
Parameter dict
Dictionary for key (OPTIONAL)
Parameter key
Key {Promise} Returns a promise
method iosSuite
static iosSuite: (suiteName: string) => Object;
method remove
static remove: (dict: string, key?: string) => Promise<any>;
Remove value from preferences
Parameter dict
Dictionary for key (OPTIONAL)
Parameter key
Key {Promise} Returns a promise
method show
static show: () => Promise<any>;
Show native preferences interface
{Promise} Returns a promise
method store
static store: (dict: string, key: string, value?: string) => Promise<any>;
Set a preference value
Parameter dict
Dictionary for key (OPTIONAL)
Parameter key
Key
Parameter value
Value {Promise} Returns a promise
method suite
static suite: (suiteName: string) => Object;
Return named configuration context In iOS you'll get a suite configuration, on Android — named file Supports: Android, iOS
Parameter suiteName
suite name
Returns
{Object} Custom object, bound to that suite
method watch
static watch: (subscribe: boolean) => Observable<any>;
Show native preferences interface
Parameter subscribe
true value to subscribe, false - unsubscribe {Observable} Returns an observable
class AppRate
class AppRate {}
App Rate The AppRate plugin makes it easy to prompt the user to rate your app, either now, later, or never.
Requires Cordova plugin: cordova-plugin-apprate. For more info, please see the [AppRate plugin docs](https://github.com/pushandplay/cordova-plugin-apprate).
import { AppRate } from 'ionic-native';AppRate.preferences.storeAppURL = {ios: '<my_app_id>',android: 'market://details?id=<package_name>',windows: 'ms-windows-store://review/?ProductId=<Store_ID>'};AppRate.promptForRating(false);AppRatePreferences AppRateStoreAppUrls AppRateCallbacks
property preferences
static preferences: AppRatePreferences;
Configure various settings for the Rating View. See table below for options
method promptForRating
static promptForRating: (immediately: boolean) => void;
Prompts the user for rating
Parameter immediately
Show the rating prompt immediately.
class AppUpdate
class AppUpdate {}
AppUpdate This plugin does self-update for android
You should first host an XML file on your server with the following data in it:
<update><version>302048</version><name>APK Name</name><url>https://your-remote-api.com/YourApp.apk</url></update>Then use the following code:
import { AppUpdate } from 'ionic-native';let updateUrl = 'http://your-remote-api.com/update.xml';AppUpdate.checkAppUpdate(updateUrl);The plugin will compare the app version and update it automatically if the API has a newer version to install.
method checkAppUpdate
static checkAppUpdate: (updateUrl: string) => Promise<any>;
Check and update
Parameter updateUrl
update api url {Promise} Returns a promise that resolves when something happens
class AppVersion
class AppVersion {}
App Version Reads the version of your app from the target build settings.
Requires Cordova plugin:
cordova-plugin-app-version
. For more info, please see the [Cordova App Version docs](https://github.com/whiteoctober/cordova-plugin-app-version).import { AppVersion } from 'ionic-native';AppVersion.getAppName();AppVersion.getPackageName();AppVersion.getVersionCode();AppVersion.getVersionNumber();
method getAppName
static getAppName: () => Promise<any>;
Returns the name of the app
Returns
{Promise}
method getPackageName
static getPackageName: () => Promise<any>;
Returns the package name of the app
Returns
{Promise}
method getVersionCode
static getVersionCode: () => Promise<any>;
Returns the build identifier of the app
Returns
{Promise}
method getVersionNumber
static getVersionNumber: () => Promise<any>;
Returns the version of the app
Returns
{Promise}
class BackgroundFetch
class BackgroundFetch {}
BackgroundFetch iOS Background Fetch Implementation. See: https://developer.apple.com/reference/uikit/uiapplication#1657399 iOS Background Fetch is basically an API which wakes up your app about every 15 minutes (during the user's prime-time hours) and provides your app exactly 30s of background running-time. This plugin will execute your provided callbackFn whenever a background-fetch event occurs. There is no way to increase the rate which a fetch-event occurs and this plugin sets the rate to the most frequent possible value of UIApplicationBackgroundFetchIntervalMinimum -- iOS determines the rate automatically based upon device usage and time-of-day (ie: fetch-rate is about ~15min during prime-time hours; less frequently when the user is presumed to be sleeping, at 3am for example). For more detail, please see https://github.com/transistorsoft/cordova-plugin-background-fetch
import { BackgroundFetch } from 'ionic-native';// When device is ready :platform.ready().then(() => {let config = {stopOnTerminate: false, // Set true to cease background-fetch from operating after user "closes" the app. Defaults to true.};BackgroundFetch.configure(() => {console.log('[js] BackgroundFetch initiated');// perform some ajax request to server hereYou MUST called #finish so that native-side can signal completion of the background-thread to the os.BackgroundFetch.finish();}, (error) => {console.log('- BackgroundFetch failed', error);}, config);});// Start the background-fetch API. Your callbackFn provided to #configure will be executed each time a background-fetch event occurs. NOTE the #configure method automatically calls #start. You do not have to call this method after you #configure the pluginBackgroundFetch.start();// Stop the background-fetch API from firing fetch events. Your callbackFn provided to #configure will no longer be executed.BackgroundFetch.stop();BackgroundFetchConfig
method configure
static configure: ( callbackFn: Function, errorCallback: Function, config: BackgroundFetchConfig) => any;
Configures the plugin's fetch callbackFn
Parameter callbackFn
This callback will fire each time an iOS background-fetch event occurs (typically every 15 min).
Parameter errorCallback
The failureFn will be called if the device doesn't support background-fetch.
Parameter config
Configuration for plugin Location object, which tries to mimic w3c Coordinates interface. See http://dev.w3.org/geo/api/spec-source.html#coordinates_interface Callback to be executed every time a geolocation is recorded in the background.
method finish
static finish: () => void;
You MUST call this method in your fetch callbackFn provided to #configure in order to signal to iOS that your fetch action is complete. iOS provides only 30s of background-time for a fetch-event -- if you exceed this 30s, iOS will kill your app.
method start
static start: () => Promise<any>;
Start the background-fetch API. Your callbackFn provided to #configure will be executed each time a background-fetch event occurs. NOTE the #configure method automatically calls #start. You do not have to call this method after you #configure the plugin
Returns
{Promise}
method stop
static stop: () => Promise<any>;
Stop the background-fetch API from firing fetch events. Your callbackFn provided to #configure will no longer be executed.
Returns
{Promise}
class BackgroundGeolocation
class BackgroundGeolocation {}
BackgroundGeolocation This plugin provides foreground and background geolocation with battery-saving "circular region monitoring" and "stop detection". For more detail, please see https://github.com/mauron85/cordova-plugin-background-geolocation
import { BackgroundGeolocation } from 'ionic-native';// When device is ready :platform.ready().then(() => {// IMPORTANT: BackgroundGeolocation must be called within app.ts and or before Geolocation. Otherwise the platform will not ask you for background tracking permission.// BackgroundGeolocation is highly configurable. See platform specific configuration optionslet config = {desiredAccuracy: 10,stationaryRadius: 20,distanceFilter: 30,debug: true, // enable this hear sounds for background-geolocation life-cycle.stopOnTerminate: false, // enable this to clear background location settings when the app terminates};BackgroundGeolocation.configure((location) => {console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude);// IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished,// and the background-task may be completed. You must do this regardless if your HTTP request is successful or not.// IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background.BackgroundGeolocation.finish(); // FOR IOS ONLY}, (error) => {console.log('BackgroundGeolocation error');}, config);// Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app.BackgroundGeolocation.start();})// If you wish to turn OFF background-tracking, call the #stop method.BackgroundGeolocation.stop();BackgroundGeolocationResponse BackgroundGeolocationConfig
property Accuracy
static Accuracy: any;
Desired accuracy in meters. Possible values [0, 10, 100, 1000].
The lower the number, the more power devoted to GeoLocation resulting in higher accuracy readings.
1000 results in lowest power drain and least accurate readings.
Possible values: HIGH: 0
MEDIUM: 10
LOW: 100
PASSIVE: 1000
enum {number}
property LocationProvider
static LocationProvider: any;
Set location service provider
See Also
https://github.com/mauron85/cordova-plugin-background-geolocation/wiki/Android-providers
Possible values: ANDROID_DISTANCE_FILTER_PROVIDER: 0,
ANDROID_ACTIVITY_PROVIDER: 1
{number}
property Mode
static Mode: any;
Used in the switchMode function
Possible values: BACKGROUND: 0 FOREGROUND: 1
{number}
method changePace
static changePace: (isMoving: boolean) => Promise<any>;
Force the plugin to enter "moving" or "stationary" state
Parameter isMoving
Returns
{Promise}
method configure
static configure: (options: BackgroundGeolocationConfig) => Observable<any>;
Configure the plugin.
Parameter options
options An object of type Config {Observable}
method deleteAllLocations
static deleteAllLocations: () => Promise<any>;
Delete all stored locations.
Returns
{Promise}
method deleteLocation
static deleteLocation: (locationId: number) => Promise<any>;
Delete stored location by given locationId.
Parameter locationId
Returns
{Promise}
method finish
static finish: () => Promise<any>;
Inform the native plugin that you're finished, the background-task may be completed
Returns
{Promise}
method getLocations
static getLocations: () => Promise<any>;
Method will return all stored locations. Locations are stored when: - config.stopOnTerminate is false and main activity was killed by the system or - option.debug is true
Returns
{Promise}
method getLogEntries
static getLogEntries: (limit: number) => Promise<any>;
Return all logged events. Useful for plugin debugging. Parameter limit limits number of returned entries.
Parameter limit
Limits the number of entries
Returns
{Promise}
See Also
https://github.com/mauron85/cordova-plugin-background-geolocation/tree/v2.2.1#debugging for more information.
method getStationaryLocation
static getStationaryLocation: () => Promise<BackgroundGeolocationResponse>;
Returns current stationaryLocation if available. null if not
Returns
{Promise}
method getValidLocations
static getValidLocations: () => Promise<any>;
Method will return locations, which has not been yet posted to server. NOTE: Locations does contain locationId.
Returns
{Promise}
method isLocationEnabled
static isLocationEnabled: () => Promise<number>;
Check if location is enabled on the device
Returns
{Promise} Returns a promise with int argument that takes values 0, 1 (true).
method onStationary
static onStationary: () => Promise<any>;
Add a stationary-region listener. Whenever the devices enters "stationary-mode", your #success callback will be executed with #location param containing #radius of region
Returns
{Promise}
method setConfig
static setConfig: (options: BackgroundGeolocationConfig) => Promise<any>;
Setup configuration
Parameter options
Returns
{Promise}
method showAppSettings
static showAppSettings: () => void;
Display app settings to change permissions
method showLocationSettings
static showLocationSettings: () => void;
Display device location settings
method start
static start: () => Promise<any>;
Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app.
Returns
{Promise}
method stop
static stop: () => Promise<any>;
Turn OFF background-tracking
Returns
{Promise}
method stopWatchingLocationMode
static stopWatchingLocationMode: () => Promise<any>;
Stop watching for location mode changes.
Returns
{Promise}
method switchMode
static switchMode: (modeId: number) => Promise<any>;
Normally plugin will handle switching between BACKGROUND and FOREGROUND mode itself. Calling switchMode you can override plugin behavior and force plugin to switch into other mode.
In FOREGROUND mode plugin uses iOS local manager to receive locations and behavior is affected by option.desiredAccuracy and option.distanceFilter. In BACKGROUND mode plugin uses significant changes and region monitoring to receive locations and uses option.stationaryRadius only.
BackgroundGeolocation.Mode.FOREGROUND BackgroundGeolocation.Mode.BACKGROUND
*
Parameter modeId
Returns
{Promise}
method watchLocationMode
static watchLocationMode: () => Promise<boolean>;
Method can be used to detect user changes in location services settings. If user enable or disable location services then success callback will be executed. In case or error (SettingNotFoundException) fail callback will be executed.
Returns
{Promise}
class BackgroundMode
class BackgroundMode {}
Background Mode Cordova plugin to prevent the app from going to sleep while in background. Requires Cordova plugin: cordova-plugin-background-mode. For more info about plugin, vist: https://github.com/katzer/cordova-plugin-background-mode
import { BackgroundMode } from 'ionic-native';BackgroundMode.enable();BackgroundModeConfiguration
method configure
static configure: (options?: BackgroundModeConfiguration) => Promise<any>;
Modify the displayed information. Available only for Android platform.
Parameter options
Any options you want to update. See table below.
method disable
static disable: () => Promise<any>;
Disable the background mode. Once the background mode has been disabled, the app will be paused when in background.
method enable
static enable: () => void;
Enable the background mode. Once called, prevents the app from being paused while in background.
method excludeFromTaskList
static excludeFromTaskList: () => void;
Exclude the app from the recent task list works on Android 5.0+.
method isActive
static isActive: () => boolean;
Can be used to get the information if the background mode is active.
Returns
{boolean} returns a boolean that indicates if the background mode is active.
method isEnabled
static isEnabled: () => boolean;
Checks if background mode is enabled or not.
Returns
{boolean} returns a boolean that indicates if the background mode is enabled.
method isScreenOff
static isScreenOff: () => Promise<boolean>;
The method works async instead of isActive() or isEnabled().
method moveToBackground
static moveToBackground: () => void;
Android allows to programmatically move from foreground to background.
method moveToForeground
static moveToForeground: () => void;
Android allows to programmatically move from background to foreground.
method on
static on: (event: string) => Observable<any>;
Listen for events that the plugin fires. Available events are
enable
,disable
,activate
,deactivate
andfailure
.Parameter event
Event name
Returns
{Observable}
method overrideBackButton
static overrideBackButton: () => void;
Override the back button on Android to go to background instead of closing the app.
method setDefaults
static setDefaults: (options?: BackgroundModeConfiguration) => Promise<any>;
Override the default title, ticker and text. Available only for Android platform.
Parameter options
List of option to configure. See table below
method unlock
static unlock: () => void;
Turn screen on and show app even locked
method wakeUp
static wakeUp: () => void;
Turn screen on
class Backlight
class Backlight {}
Backlight This plugin adds turning on/off the device backlight.
import { Backlight } from 'ionic-native';// Turn backlight onBacklight.on().then(() => console.log('backlight on'));// Turn backlight offBacklight.off().then(() => console.log('backlight off'));Modifiers
@beta
class Badge
class Badge {}
Badge The essential purpose of badge numbers is to enable an application to inform its users that it has something for them — for example, unread messages — when the application isn’t running in the foreground.
Requires Cordova plugin: cordova-plugin-badge. For more info, please see the [Badge plugin docs](https://github.com/katzer/cordova-plugin-badge).
import { Badge } from 'ionic-native';Badge.set(10);Badge.increase(1);Badge.clear();
method clear
static clear: () => Promise<boolean>;
Clear the badge of the app icon.
Returns
{Promise}
method decrease
static decrease: (decreaseBy: number) => Promise<any>;
Decrease the badge number.
Parameter decreaseBy
Count to subtract from the current badge number
Returns
{Promise}
method get
static get: () => Promise<any>;
Get the badge of the app icon.
Returns
{Promise}
method hasPermission
static hasPermission: () => Promise<any>;
Determine if the app has permission to show badges.
Returns
{Promise}
method increase
static increase: (increaseBy: number) => Promise<any>;
Increase the badge number.
Parameter increaseBy
Count to add to the current badge number
Returns
{Promise}
method registerPermission
static registerPermission: () => Promise<any>;
Register permission to set badge notifications
Returns
{Promise}
method set
static set: (badgeNumber: number) => Promise<any>;
Set the badge of the app icon.
Parameter badgeNumber
The new badge number.
Returns
{Promise}
class BarcodeScanner
class BarcodeScanner {}
Barcode Scanner The Barcode Scanner Plugin opens a camera view and automatically scans a barcode, returning the data back to you.
Requires Cordova plugin:
phonegap-plugin-barcodescanner
. For more info, please see the [BarcodeScanner plugin docs](https://github.com/phonegap/phonegap-plugin-barcodescanner).import { BarcodeScanner } from 'ionic-native';BarcodeScanner.scan().then((barcodeData) => {// Success! Barcode data is here}, (err) => {// An error occurred});BarcodeScannerOptions
property Encode
static Encode: any;
method encode
static encode: (type: string, data: any) => Promise<any>;
Encodes data into a barcode. NOTE: not well supported on Android
Parameter type
Type of encoding
Parameter data
Data to encode
Returns
{Promise}
method scan
static scan: (options?: BarcodeScannerOptions) => Promise<any>;
Open the barcode scanner.
Parameter options
Optional options to pass to the scanner
Returns
{Promise} Returns a Promise that resolves with scanner data, or rejects with an error.
class Base64ToGallery
class Base64ToGallery {}
Base64 To Gallery This plugin allows you to save base64 data as a png image into the device
import { Base64ToGallery } from 'ionic-native';Base64ToGallery.base64ToGallery(base64Data, 'img_').then(res => console.log('Saved image to gallery ', res),err => console.log('Error saving image to gallery ', err));
method base64ToGallery
static base64ToGallery: ( data: string, options?: { prefix?: string; mediaScanner?: boolean }) => Promise<any>;
Converts a base64 string to an image file in the device gallery
Parameter data
The actual base64 string that you want to save
Parameter options
(optional) An object with properties: prefix: string, mediaScanner: boolean. Prefix will be prepended to the filename. If true, mediaScanner runs Media Scanner on Android and saves to Camera Roll on iOS; if false, saves to Library folder on iOS.
Returns
{Promise} returns a promise that resolves when the image is saved.
class BatteryStatus
class BatteryStatus {}
Battery Status Requires Cordova plugin: cordova-plugin-batterystatus. For more info, please see the [BatteryStatus plugin docs](https://github.com/apache/cordova-plugin-battery-status).
import { BatteryStatus } from 'ionic-native';// watch change in battery statuslet subscription = BatteryStatus.onChange().subscribe((status: StatusObject) => {console.log(status.level, status.isPlugged);});// stop watchsubscription.unsubscribe();BatteryStatusResponse
method onChange
static onChange: () => Observable<BatteryStatusResponse>;
Watch the change in battery level
Returns
{Observable} Returns an observable that pushes a status object
method onCritical
static onCritical: () => Observable<BatteryStatusResponse>;
Watch when the battery level goes to critial
Returns
{Observable} Returns an observable that pushes a status object
method onLow
static onLow: () => Observable<BatteryStatusResponse>;
Watch when the battery level goes low
Returns
{Observable} Returns an observable that pushes a status object
class BLE
class BLE {}
BLE This plugin enables communication between a phone and Bluetooth Low Energy (BLE) peripherals.
The plugin provides a simple JavaScript API for iOS and Android.
- Scan for peripherals - Connect to a peripheral - Read the value of a characteristic - Write new value to a characteristic - Get notified when characteristic's value changes
Advertising information is returned when scanning for peripherals. Service, characteristic, and property info is returned when connecting to a peripheral. All access is via service and characteristic UUIDs. The plugin manages handles internally.
Simultaneous connections to multiple peripherals are supported.
## Peripheral Data
Peripheral Data is passed to the success callback when scanning and connecting. Limited data is passed when scanning.
{"name": "Battery Demo","id": "20:FF:D0:FF:D1:C0","advertising": [2,1,6,3,3,15,24,8,9,66,97,116,116,101,114,121],"rssi": -55}After connecting, the peripheral object also includes service, characteristic and descriptor information.
{"name": "Battery Demo","id": "20:FF:D0:FF:D1:C0","advertising": [2,1,6,3,3,15,24,8,9,66,97,116,116,101,114,121],"rssi": -55,"services": ["1800","1801","180f"],"characteristics": [{"service": "1800","characteristic": "2a00","properties": ["Read"]},{"service": "1800","characteristic": "2a01","properties": ["Read"]},{"service": "1801","characteristic": "2a05","properties": ["Read"]},{"service": "180f","characteristic": "2a19","properties": ["Read"],"descriptors": [{"uuid": "2901"},{"uuid": "2904"}]}]}## Advertising Data Bluetooth advertising data is returned in when scanning for devices. The format format varies depending on your platform. On Android advertising data will be the raw advertising bytes. iOS does not allow access to raw advertising data, so a dictionary of data is returned.
The advertising information for both Android and iOS appears to be a combination of advertising data and scan response data.
### Android
{"name": "demo","id": "00:1A:7D:DA:71:13","advertising": ArrayBuffer,"rssi": -37}Convert the advertising info to a Uint8Array for processing.
var adData = new Uint8Array(peripheral.advertising)
### iOS
Note that iOS uses the string value of the constants for the [Advertisement Data Retrieval Keys](https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/CBCentralManagerDelegate_Protocol/index.html#//apple_ref/doc/constant_group/Advertisement_Data_Retrieval_Keys). This will likely change in the future.
{"name": "demo","id": "D8479A4F-7517-BCD3-91B5-3302B2F81802","advertising": {"kCBAdvDataChannel": 37,"kCBAdvDataServiceData": {"FED8": {"byteLength": 7 // data not shown}},"kCBAdvDataLocalName": "demo","kCBAdvDataServiceUUIDs": ["FED8"],"kCBAdvDataManufacturerData": {"byteLength": 7 // data not shown},"kCBAdvDataTxPowerLevel": 32,"kCBAdvDataIsConnectable": true},"rssi": -53}## Typed Arrays
This plugin uses typed Arrays or ArrayBuffers for sending and receiving data.
This means that you need convert your data to ArrayBuffers before sending and from ArrayBuffers when receiving.
// ASCII onlyfunction stringToBytes(string) {var array = new Uint8Array(string.length);for (var i = 0, l = string.length; i < l; i++) {array[i] = string.charCodeAt(i);}return array.buffer;}// ASCII onlyfunction bytesToString(buffer) {return String.fromCharCode.apply(null, new Uint8Array(buffer));}You can read more about typed arrays in these articles on [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays) and [HTML5 Rocks](http://www.html5rocks.com/en/tutorials/webgl/typed_arrays/).
## UUIDs
UUIDs are always strings and not numbers. Some 16-bit UUIDs, such as '2220' look like integers, but they're not. (The integer 2220 is 0x8AC in hex.) This isn't a problem with 128 bit UUIDs since they look like strings 82b9e6e1-593a-456f-be9b-9215160ebcac. All 16-bit UUIDs should also be passed to methods as strings.
method connect
static connect: (deviceId: string) => Observable<any>;
Connect to a peripheral.
BLE.connect('12:34:56:78:9A:BC').subscribe(peripheralData => {console.log(peripheralData);},peripheralData => {console.log('disconnected');});Parameter deviceId
UUID or MAC address of the peripheral Returns an Observable that notifies of connect/disconnect.
method disconnect
static disconnect: (deviceId: string) => Promise<any>;
Disconnect from a peripheral.
BLE.disconnect('12:34:56:78:9A:BC').then(() => {console.log('Disconnected');});Parameter deviceId
UUID or MAC address of the peripheral Returns a Promise
method enable
static enable: () => Promise<any>;
Enable Bluetooth on the device (Android only).
Returns
{Promise}
method isConnected
static isConnected: (deviceId: string) => Promise<any>;
Report the connection status.
BLE.isConnected('FFCA0B09-CB1D-4DC0-A1EF-31AFD3EDFB53').then(() => { console.log('connected'); },() => { console.log('not connected'); });Parameter deviceId
UUID or MAC address of the peripheral
Returns
{Promise}
method isEnabled
static isEnabled: () => Promise<void>;
Report if bluetooth is enabled.
Returns
{Promise} Returns a Promise that resolves if Bluetooth is enabled, and rejects if disabled.
method read
static read: ( deviceId: string, serviceUUID: string, characteristicUUID: string) => Promise<any>;
Read the value of a characteristic.
Parameter deviceId
UUID or MAC address of the peripheral
Parameter serviceUUID
UUID of the BLE service
Parameter characteristicUUID
UUID of the BLE characteristic Returns a Promise
method scan
static scan: (services: string[], seconds: number) => Observable<any>;
Scan and discover BLE peripherals for the specified amount of time.
BLE.scan([], 5).subscribe(device => {console.log(JSON.stringify(device));});Parameter services
List of service UUIDs to discover, or
[]
to find all devicesParameter seconds
Number of seconds to run discovery
Returns
{Observable} Returns an Observable that notifies of each peripheral that is discovered during the specified time.
method showBluetoothSettings
static showBluetoothSettings: () => Promise