# @platformbuilders/use-notifications

> [![Build Status][check-badge]][workflows] [![codecov][codecov]](https://codecov.io/gh/platformbuilders/use-notifications) [![npm][npm-badge]][npm] [![MIT][license-badge]][license]

Latest version **0.1.9** (published 2023-05-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @platformbuilders/use-notifications
pnpm add @platformbuilders/use-notifications
yarn add @platformbuilders/use-notifications
bun add @platformbuilders/use-notifications
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.9 |
| Published | 2023-05-30 |
| First published | 2020-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 73.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Platform Builders |
| Maintainers | luancteixeira, dev-builders |

## Links

- npm: https://www.npmjs.com/package/@platformbuilders/use-notifications
- Repository: https://github.com/platformbuilders/use-notifications
- Homepage: https://github.com/platformbuilders/use-notifications#readme
- Issues: https://github.com/platformbuilders/use-notifications/issues
- npm.io page: https://npm.io/package/@platformbuilders/use-notifications

## Recent versions

- 0.1.9 (latest) — 2023-05-30
- 0.1.8 — 2023-03-15
- 0.1.7 — 2022-11-29
- 0.1.6 — 2022-11-14
- 0.1.5 — 2022-10-14
- 0.0.11 — 2022-10-14
- 0.1.4 — 2022-10-14
- 0.1.3 — 2022-10-13
- 0.0.3 — 2020-10-24
- 0.0.1 — 2020-10-24

## README

[![Build Status][check-badge]][workflows]
[![codecov][codecov]](https://codecov.io/gh/platformbuilders/use-notifications)
[![npm][npm-badge]][npm]
[![MIT][license-badge]][license]

[npm-badge]: https://img.shields.io/npm/v/@platformbuilders/use-notifications.svg
[npm]: https://www.npmjs.com/package/@platformbuilders/use-notifications
[license-badge]: https://img.shields.io/dub/l/vibe-d.svg
[license]: https://raw.githubusercontent.com/platformbuilders/use-notifications/master/LICENSE.md
[workflows]: https://github.com/platformbuilders/use-notifications/actions
[check-badge]: https://github.com/platformbuilders/use-notifications/workflows/check/badge.svg
[codecov]: https://codecov.io/gh/platformbuilders/use-notifications/branch/master/graph/badge.svg

# @platformbuilders/use-notification

Wrapping up `@react-native-firebase/messaging` and [`@notifee/react-native`](https://notifee.app/react-native/docs/overview) as a hook for simpler usage.

## Install

```
yarn add @react-native-firebase/messaging @react-native-firebase/app @notifee/react-native @platformbuilders/use-notifications
```

then, navigate to `cd ios` and run `pod install`

## Usage to configure

```
import { useNotifications } from '@platformbuilders/use-notifications';

const { configureNotifications, getFCMToken } = useNotifications();

const onRegisterNotification = async (token) => {
  console.log('LOG: onRegisterNotification -> token', token);
};

const onReceiveNotification = (notification) => {
  console.log('LOG: onNotification -> notification', notification);
};

const onOpenNotification = (notification) => {
  console.log('LOG: onOpenNotification -> notification', notification);
};

const onTokenRefresh = (token) => {
  console.log('LOG: onTokenRefresh -> token', token);
};

const getFirebaseToken = async () => {
  const fcmToken = await getFCMToken();
  console.log('LOG: getFirebaseToken -> fcmToken', fcmToken);
};

useEffect(() => {
  configureNotifications({
    onRegister: onRegisterNotification,
    onNotification: onReceiveNotification,
    onNotificationOpened: onOpenNotification, // iOS
    onTokenRefresh: onTokenRefresh
  });
}, []);

```

## Usage to display notifications

```
import { useNotifications } from '@platformbuilders/use-notifications';

const { displayNotification } = useNotifications();

useEffect(() => {
  displayNotification({
    title: 'Bem vindo ao App',
    body: 'Faça login para continuar',
  });
}, []);

```

### New Version

- To **test** locally see: [Testando NPM packages localmente](https://www.notion.so/platformbuilders/Testando-NPM-packages-localmente-28423b323abe4b3da1257283bff7d99d)

- To **publish** a new version see: [Testando NPM packages localmente](https://www.notion.so/platformbuilders/Criando-e-distribuindo-Libs-f6de8ccf543c4485ac0cc17379480975)

---
_Source: https://npm.io/package/@platformbuilders/use-notifications · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
