# @deltax-sdk/ionic-deltax-mobile-sdk

> ## DeltaX Mobile SDK Cordova Plugin

Latest version **1.0.3** (published 2019-08-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install @deltax-sdk/ionic-deltax-mobile-sdk
pnpm add @deltax-sdk/ionic-deltax-mobile-sdk
yarn add @deltax-sdk/ionic-deltax-mobile-sdk
bun add @deltax-sdk/ionic-deltax-mobile-sdk
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2019-08-23 |
| First published | 2019-08-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 31.5 KB |
| Known vulnerabilities | 0 (+8 in 1 direct dependencies) |
| Install scripts | no |
| Author | AdBox Software Private Limited |
| Maintainers | ak47surve, ganeshpg |
| Keywords | DeltaX, DeltaX Mobile, DeltaX Mobile SDK, DeltaX SDK, DeltaXMobileSDK, dxmobile, dxmobilesdk, dx mobile sdk, dx sdk, dx mobile cordova, cordova-android |

## Links

- npm: https://www.npmjs.com/package/@deltax-sdk/ionic-deltax-mobile-sdk
- npm.io page: https://npm.io/package/@deltax-sdk/ionic-deltax-mobile-sdk

## Dependencies (1)

- [@angular/core](https://npm.io/package/@angular/core.md) ^5.0.3

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2019-08-23
- 1.0.2 — 2019-08-23

## README

# DxMobileSdk

  

  

## Description

  

  

DxMobileSdk is an angular service which acts as an interface to *@deltax-sdk/cordova-plugin-deltax-mobile-sdk*. It is compatible with ionic 3+ applications built on angular. 
  

  

**Usage**

**Installation:**

First, install [cordova-plugin-deltax-mobile-sdk](https://www.npmjs.com/package/@deltax-sdk/cordova-plugin-deltax-mobile-sdk) by running one of the following commands (depending on the ionic version):

    ionic cordova plugin add @deltax-sdk/cordova-plugin-deltax-mobile-sdk

OR

    cordova plugin add @deltax-sdk/cordova-plugin-deltax-mobile-sdk

Then install the DxMobileSdk wrapper:

    npm install --save @deltax-sdk/ionic-deltax-mobile-sdk

Next, add DxMobileSdk as a provider in your NgModule declaration (for example, in `src/app/app.module.ts`): 

```
import { DxMobileSdk } from '@deltax-sdk/ionic-deltax-mobile-sdk/DxMobileSdk';

@NgModule({
  declarations: [
    // ...
  ],
  imports: [
    // ...
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    // ...
  ],
  providers: [
    // ...
    , DxMobileSdk
  ]
})
export class AppModule {}
```

Initialize the plugin (ideally, in app.component.ts constructor on platform ready, as follows) :

```
import { DxMobileSdk } from '@deltax-sdk/ionic-deltax-mobile-sdk/DxMobileSdk';
import { Platform } from  'ionic-angular';

export class MyApp {
  constructor(private platform : Platform, private dxPlugin: DxMobileSdk ) { 
	  this.platform.ready().then( async () => {
		   await this.dxPlugin.initPlugin();
	   });  
  }
  //...
}
```
Note: It is necessary to wait for a dxPlugin method call to end before making another dxPlugin method call in order to avoid unintended consequences. For example, if trackEvent is called before initDxTracker has completed execution, then the sdk might not have initialized the tracker for the particular business profile, and it might throw an error. We recommend using async await to avoid promise hell.

Finally, inject it into any of your components or pages:
```
import { DxMobileSdk } from '@deltax-sdk/ionic-deltax-mobile-sdk/DxMobileSdk';

export class MyApp {
  constructor(private dxPlugin: DxMobileSdk ) { }

  //...
  var params:any = {};
  params.Stage1 = '5';
  params.Stage2 = '10.3';
  params.GoalId = '6AMDV2';
  this.dxPlugin.trackEvent(params, 'xxxx1234').then(
				( ) => {
					//Statements to execute on success
				},
				(err) => {
					//Statements to execute on error
				}
  );  
}
```
  
 | Methods|Description|
| :------------- |------------:|
|initPlugin( ) => Promise(void, Error)|Returns a promise that resolves when the plugin is initialised|
|initDxTracker(businessProfileEncodedId  :  string, setDefault?  :  boolean) => Promise(void, Error)| Returns a promise that resolves when the tracker is initialized for the given businessProfileEncodedId. If setDefault is passed and it is true, the initialized tracker will also be set as default tracker|
|setDefaultInstance(businessProfileEncodedId  :  string) => Promise(void, Error)|Returns a promise that resolves when the existing tracker for the businessProfileEncodedId is set as default tracker|
|setCustomerEmail(email  :  string, businessProfileEncodedId?  :  string, isEncoded?  :  boolean) => Promise(void, Error)|Returns a promise that resolves when the default customer email is set. If businessProfileEncodedId is passed, the default customer email is set for that particular tracker instance. Else, default customer email is set for the default tracker instance. If isEncoded is passed and it is true, the tracker expects an encoded value for customer email. By default, the tracker encodes the given customer email before the event is tracked
|setCustomerPhoneNumber(phoneNumber  :  string, businessProfileEncodedId?  :  string, isEncoded?  :  boolean) => Promise(void, Error)| Refer to setCustomerEmail method description
|setCustomerId(id  :  string, businessProfileEncodedId?  :  string) => Promise(void, Error)| Returns a promise that resolves when the default customer id is set. If businessProfileEncodedId is passed, the default customer email is set for that particular tracker instance. Else, default customer email is set for the default tracker instance
|trackEvent(params  :  any, businessProfileEncodedId?  :  string) => Promise(void, Error)| Returns a promise that resolves when the event has been successfully tracked. Refer to Event Parameters section for supported properties in params object|
|enableTracking( ) => Promise(void, Error)| Returns a promise that resolves when tracking is enabled in the SDK|
|disableTracking( ) => Promise(void, Error)|Returns a promise that resolves when tracking is disabled in the SDK|
|trackClick(uri  :  string, businessProfileEncodedId?  :  string) => Promise(void, Error)|Returns a promise that resolves when a deep link click event is tracked for the given URI string|

**Event Parameters**

The first parameter of the trackEvent method is an object which supports the following properties with string values. Any of these properties which are set will be passed in the event which is tracked.

 - TransactionId	
 - CurrencyCode	
 - TransactionValue	
 - Quantity	
 - CustomerId	
 - CustomerMail
 - CustomerPhone
 - GoalId	
 - Stage1	
 - Stage2	
 - Stage3	
 - Stage4	
 - Stage5	
 - Stage6	
 - Stage7	
 - Stage8	
 - Stage9	
 - Stage10	
 - XCart	

Refer to [cordova-plugin-deltax-mobile-sdk](https://www.npmjs.com/package/@deltax-sdk/cordova-plugin-deltax-mobile-sdk) for detailed documentation.

---
_Source: https://npm.io/package/@deltax-sdk/ionic-deltax-mobile-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
