0.1.9 • Published 12 months ago

@platformbuilders/use-notifications v0.1.9

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Build Status codecov npm MIT

@platformbuilders/use-notification

Wrapping up @react-native-firebase/messaging and @notifee/react-native 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

0.1.9

12 months ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

2 years ago

0.0.11

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.5

2 years ago

0.0.3

4 years ago

0.0.1

4 years ago