Skip to content

0.1.0

Compare
Choose a tag to compare
@Denise-Ng Denise-Ng released this 12 Jan 20:17
· 3 commits to master since this release

We added the useNotificationStatus hook.

It works as such:

import { useNotificationStatus } from 'react-native-use-permissions';
import { RESULTS } from 'react-native-permissions';

  .... 

  /** State */
  const [notificationStatus, setNotificationStatus] = useNotificationStatus();

  return (
    <Button title="Enable Notifications" onPress={onEnableNotifications} />
  )

  /**
   * Asks for notification if we haven't asked for it yet
   */
  function onEnableNotifications() {
    if (notificationStatus === RESULTS.DENIED) {
      requestNotifications(['alert', 'badge']).then((value) => {
        setNotificationStatus(value.status);
      });
    }
  }