# Cordova Singular plugin for Android and iOS.
[](https://badge.fury.io/js/https://www.npmjs.com/package/singular_cordova_sdk)
[](https://opensource.org/licenses/MIT)
[](https://www.npmjs.com/package/singular_cordova_sdk)
## Table of content
- [SDK versions](#plugin-build-for)
- [Installation](#installation)
- [Guides](#guides)
- [Setup](#setup)
- [Sample App](#sample-app)
- [Ionic](#ionic)
### This plugin is built for
- iOS Singular SDK **v12.14.0**
- Android Singular SDK **12.16.0**
## 📲Installation
```
$ cordova plugin add singular_cordova_sdk
```
> **_NOTE:_** for Ionic installation see [this](#ionic) section
## 📖 Guides
Great installation, usage and setup guides can be viewed [here](https://support.singular.net/hc/en-us/articles/8586543222683).
## 🚀 Setup
#### Prepare your Singular API Key and Secret Key
Add the following lines to your code to be able to initialize tracking with your own Singular API Key and Secret Key:
```javascript
document.addEventListener('deviceready', function() {
var singularConfig = new cordova.plugins.SingularCordovaSdk.SingularConfig("apiKey", "secretKey");
cordova.plugins.SingularCordovaSdk.init(singularConfig);
}, false);
```
---
## 📱 Sample App
A sample app can be found in [here](https://github.com/singular-labs/Singular-Cordova-SDK/tree/main/SampleApp)
## 📍 Ionic
### Using the `cordova` object directly
Install the cordova plugin:
```
$ ionic cordova plugin add singular_cordova_sdk
```
In your main ts file, declare a window variable:
```javascript
declare var cordova;
```
Now you can use the Singular plugin directly from cordova:
```javascript
import {Component} from '@angular/core';
import {Platform} from '@ionic/angular';
declare var cordova;
...
export class HomePage {
constructor(public platform: Platform) {
this.platform.ready().then(() => {
var singularConfig = new cordova.plugins.SingularCordovaSdk.SingularConfig("apiKey", "secretKey");
cordova.plugins.SingularCordovaSdk.init(singularConfig);
}); }}
```