# @robo-finance/cordova-push-delivery

> This plugin allows your application to receive push notifications on Android, iOS and Windows devices. Android uses Firebase Cloud Messaging. iOS uses Apple APNS Notifications. Windows uses Microsoft WNS Notifications.

Latest version **2.6.1** (published 2020-11-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @robo-finance/cordova-push-delivery
pnpm add @robo-finance/cordova-push-delivery
yarn add @robo-finance/cordova-push-delivery
bun add @robo-finance/cordova-push-delivery
```

## 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 | 2.6.1 |
| Published | 2020-11-24 |
| First published | 2019-10-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 23.1 KB |
| Known vulnerabilities | 0 (+8 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | xakzona |
| Keywords | ecosystem:cordova, cordova-android |

## Links

- npm: https://www.npmjs.com/package/@robo-finance/cordova-push-delivery
- Repository: https://github.com/RoboFinance/CordovaPushDelivery
- Homepage: https://github.com/RoboFinance/CordovaPushDelivery#readme
- Issues: https://github.com/RoboFinance/CordovaPushDelivery/issues
- npm.io page: https://npm.io/package/@robo-finance/cordova-push-delivery

## Dependencies (1)

- [xmldom](https://npm.io/package/xmldom.md) ^0.1.27

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

- 2.6.1 (latest) — 2020-11-24
- 2.5.2 — 2020-11-24
- 2.5.1 — 2020-10-14
- 2.4.0 — 2020-06-08
- 2.3.0 — 2019-11-22
- 2.2.0 — 2019-11-05
- 2.1.0 — 2019-10-30
- 2.0.0 — 2019-10-29
- 1.1.2 — 2019-10-29
- 1.1.1 — 2019-10-28
- 1.1.0 — 2019-10-28
- 1.0.0 — 2019-10-25

## README

#### Description

A plugin that overrides the ```onMessageReceived()``` method of the `phonegap-plugin-push` package.
It introduces a possibility to detect if notifications are enabled and push is received in foreground / background and sends a fallback **POST** request.

**Only Android support right now.**
#### How to install
```
cordova plugin add "phonegap-plugin-push"
cordova plugin add "@robo-finance/cordova-push-delivery"
```

### How to use

1. In the global configuration file `config.xml`, and add the <variable /> tag inside plugin directive with the attribute name = DELIVERY_URL_KEY and the value attribute with its own value:
##### Example: DELIVERY_URL_KEY = delivery_url
```xml
<variable name="DELIVERY_URL_KEY" value="delivery_url"/>
```
2. Kindly append value DELIVERY_URL_KEY (e.g. `delivery_url`) to firebase `data` on backend:
 
##### Example of data structure

```json
{
	"data" : {
		"delivery_url": "https://localhost/set-read/886d27ee-f6fd-11e9-832d-362b9e155667"
	}
}
```

After push received and processed by `phonegap-plugin-push` in foreground/background, plugin will make **POST** request to `http://localhost/set-read/886d27ee-f6fd-11e9-832d-362b9e155667` automatically.
So, it doesn't need to write any Javascript code.

It is possible to detect if plugin is installed. No available methods in the `CordovaPushDelivery` object right now.
```js
if (typeof window.CordovaPushDelivery !== 'undefined') {
    
}
```

### How it works
Because on Android must be only one `intent-filter` per action the plugin use  [intent-filter priority](https://developer.android.com/guide/topics/manifest/intent-filter-element#priority) to override `phonegap-plugin`'s FCMService.
After onMessageReceived received it call parent `super.onMessageReceived(message)`, `phonegap-plugin` processes the notification and our plugin do the following:
1. Checks that `DELIVERY_URL_KEY` (e.g. `delivery_url`) is present in firebase `data`.
2. Checks if notifications are not blocked by the user, because they cannot be read.
3. If debug mode it disables chrome's trust certificate feature (for example, to use in staging environment), affected only to current request.
4. Sends POST callback to `DELIVERY_URL_KEY` (e.g. `delivery_url`) with empty body. You should set any `notification_id` or something like that to `DELIVERY_URL_KEY` (e.g. `delivery_url`), for example, `https://localhost/set-read/886d27ee-f6fd-11e9-832d-362b9e155667`

---
_Source: https://npm.io/package/@robo-finance/cordova-push-delivery · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
