All Projects → leandrosimoes → react-native-android-notification-listener

leandrosimoes / react-native-android-notification-listener

Licence: other
React Native Android Notification Listener - Listen for status bar notifications from all applications

Programming Languages

java
68154 projects - #9 most used programming language
typescript
32286 projects
C++
36643 projects - #6 most used programming language
javascript
184084 projects - #8 most used programming language
Makefile
30231 projects
Starlark
911 projects

Projects that are alternatives of or similar to react-native-android-notification-listener

react-listener-provider
Create a ReactListenerProvider and use HOC (Higher Order Components) to listen for Events in one place.
Stars: ✭ 19 (-78.16%)
Mutual labels:  listener
Unity-EventBinder
User Interface Event decoupler
Stars: ✭ 27 (-68.97%)
Mutual labels:  listener
OneSignal-Ionic-Sample
No description or website provided.
Stars: ✭ 85 (-2.3%)
Mutual labels:  push-notifications
mobile-push
A push notification library
Stars: ✭ 21 (-75.86%)
Mutual labels:  push-notifications
expo-push-notification-helper
💬🔥This package helps you make expo push notification for React Native easy to use.
Stars: ✭ 32 (-63.22%)
Mutual labels:  push-notifications
VaporGCM
A simple Android GCM/FCM library for Swift/Vapor
Stars: ✭ 25 (-71.26%)
Mutual labels:  push-notifications
react-native-template
An opinionated template to bootstrap your next React Native app with all the time-wasting packages you need to have.
Stars: ✭ 132 (+51.72%)
Mutual labels:  push-notifications
ios
React Native Push Notification API for iOS.
Stars: ✭ 604 (+594.25%)
Mutual labels:  push-notifications
pushnotification
Push notifications with Spring Boot and OneSignal
Stars: ✭ 25 (-71.26%)
Mutual labels:  push-notifications
food-delivery-ios-app
A food delivery application built using Swift for iOS. The application uses Pushers notifications feature to send push notifications to mobile devices.
Stars: ✭ 36 (-58.62%)
Mutual labels:  push-notifications
hms-push-serverdemo-java
Java sample code encapsulates APIs of the HUAWEI Push Kit server. It provides many sample programs for your reference or usage.
Stars: ✭ 39 (-55.17%)
Mutual labels:  push-notifications
claim-reporter-pwa-poc
Example PWA application with Angular 6 and backend with Node
Stars: ✭ 39 (-55.17%)
Mutual labels:  push-notifications
GroundControl
Push notification service for Bitcoin wallets
Stars: ✭ 70 (-19.54%)
Mutual labels:  push-notifications
react-native-touchable
React-Native button helper library
Stars: ✭ 46 (-47.13%)
Mutual labels:  react-native-component
vue-music-player
🎵 basic music player, keeps your favorite musics
Stars: ✭ 77 (-11.49%)
Mutual labels:  listener
mailrise
An SMTP gateway for Apprise notifications.
Stars: ✭ 352 (+304.6%)
Mutual labels:  push-notifications
FcmNotificationHandler
Android library that helps to construct and launch system tray notifications from FCM Notification messages received when the app is in foreground mimicking the default format and behavior applied when the app is background.
Stars: ✭ 18 (-79.31%)
Mutual labels:  push-notifications
react-native-component-splitter
VS Code Extension allows splitting React Native Component into Sub-Component
Stars: ✭ 33 (-62.07%)
Mutual labels:  react-native-component
ikisocket
🧬 WebSocket wrapper with event management for Fiber https://github.com/gofiber/fiber. Based on Fiber WebSocket and inspired by Socket.io
Stars: ✭ 92 (+5.75%)
Mutual labels:  listener
hms-push-serverdemo-php
PHP sample code encapsulates APIs of the HUAWEI Push Kit server.It provides many sample PHP programs about quick access to HUAWEI Push Kit for your reference or usage.
Stars: ✭ 21 (-75.86%)
Mutual labels:  push-notifications

react-native-android-notification-listener

React Native Android Notification Listener is a library that allows you to listen for status bar notifications from all applications. (Android Only)

Codacy Badge npm version Node.js Package

Installation

  • For React Native greater or equal then 0.68.0
    • $ yarn add react-native-android-notification-listener
  • For React Native between 0.65.1 and 0.67.4
  • For React Native less then 0.65

Usage

import { AppRegistry } from 'react-native'
import RNAndroidNotificationListener, { RNAndroidNotificationListenerHeadlessJsName } from 'react-native-android-notification-listener';

// To check if the user has permission
const status = await RNAndroidNotificationListener.getPermissionStatus()
console.log(status) // Result can be 'authorized', 'denied' or 'unknown'

// To open the Android settings so the user can enable it
RNAndroidNotificationListener.requestPermission()

/**
 * Note that this method MUST return a Promise.
 * Is that why I'm using an async function here.
 */
const headlessNotificationListener = async ({ notification }) => {/**
     * This notification is a JSON string in the follow format:
     *  {
     *      "time": string,
     *      "app": string,
     *      "title": string,
     *      "titleBig": string,
     *      "text": string,
     *      "subText": string,
     *      "summaryText": string,
     *      "bigText": string,
     *      "audioContentsURI": string,
     *      "imageBackgroundURI": string,
     *      "extraInfoText": string,
     *      "groupedMessages": Array<Object> [
     *          {
     *              "title": string,
     *              "text": string
     *          }
     *      ],
     *      "icon": string (base64),
     *      "image": string (base64), // WARNING! THIS MAY NOT WORK FOR SOME APPLICATIONS SUCH TELEGRAM AND WHATSAPP
     *  }
     * 
     * Note that these properties depend on the sender configuration so many times a lot of them will be empty
     */
    
    if (notification) {
        /**
         * You could store the notifications in an external API.
         * I'm using AsyncStorage in the example project.
         */
        
        ...
    }
}

/**
 * This should be required early in the sequence
 * to make sure the JS execution environment is setup before other
 * modules are required.
 * 
 * Your entry file (index.js) would be the better place for it.
 * 
 * PS: I'm using here the constant RNAndroidNotificationListenerHeadlessJsName to ensure
 *     that I register the headless with the right name
 */
AppRegistry.registerHeadlessTask(RNAndroidNotificationListenerHeadlessJsName,	() => headlessNotificationListener)

For more details, see the example/ project in this repository

FAQ

"There are some limitations regarding the use of the Headless JS by this module that I should care about?"

Yes, there are some nuances that you should concern about. For example, since Headless JS runs in a standalone "Task" you can't interact directly with it by the touch UI. For more information about using Headless JS in React Native, I suggest you take a look at the official documentation here.


"I keep receiving the warning registerHeadlessTask or registerCancellableHeadlessTask called multiple times for the same key '${taskKey}', is that a problem?

No, this warning is here, where you can see that the task providers are stored in a set, and there's no way to delete them, so react is just complaining about the fact that we are overwriting it.


Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].