Giter Site home page Giter Site logo

shasikhan / react-native-notification-badge Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mrousavy/react-native-notification-badge

0.0 0.0 0.0 372 KB

๐Ÿ”ด A notification badge count manager for React Native

License: MIT License

JavaScript 19.21% Ruby 7.81% Objective-C 26.43% TypeScript 17.69% Swift 28.86%

react-native-notification-badge's Introduction

react-native-notification-badge

For when you don't want to use a fully featured notification manager

A very simple notification badge count manager for React Native that just works.

react-native-notification-badge GitHub stars GitHub followers

Buy Me a Coffee at ko-fi.com

API

getBadgeCount

Asynchronously returns the current Badge count.

Note: If no notification permissions have been granted yet, this will also ask the user for notification permissions (only [.badge]), so request permissions before calling this using a library like react-native-permissions

const badgeCount = await getBadgeCount()

getBadgeCountSync

Same as getBadgeCount, but synchronously.

const badgeCount = getBadgeCountSync()

setBadgeCount

Asynchronously sets the Badge count.

Note: If no notification permissions have been granted yet, this will also ask the user for notification permissions (only [.badge]), so request permissions before calling this using a library like react-native-permissions

await setBadgeCount(2)

getNotificationBadgeSetting

Asynchronously gets the current state of the "Notification Badge" permission setting.

Possible values are: 'enabled' | 'disabled' | 'notSupported' | 'unknown'

const permission = await getNotificationBadgeSetting()
if (permission === 'enabled') {
  await setBadgeCount(5)
} else {
  console.log("Badge permission has not yet been granted. I'll ask the user later")
}

requestNotificationPermissions

Asynchronously request the user to grant the specified permissions.

Possible parameter values are: ['badge' | 'alert' | 'sound' | 'carPlay' | 'criticalAlert' | 'providesAppNotificationSettings' |ย 'provisional' | 'announcement']

const granted = await requestNotificationPermissions(['badge', 'alert', 'sound'])

removeNotificationsWithThreadId

Remove all notification with the given Thread ID from the User's Notification Center.

The Thread ID is a property in the APNS payload which can be used to group notifications in iOS 10.0 or higher.

Returns the count of notifications that were removed.

const removed = await removeNotificationsWithThreadId('group-chat-2')

Other

Check out my other react-native libraries:

react-native-notification-badge's People

Contributors

mrousavy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.