Flutter plugin for notification read & reply

Overview

Reflex

Flutter plugin for notification read & reply.

GitHub GitHub code size in bytes GitHub top language GitHub language count GitHub tag (latest by date) GitHub issues GitHub Repo stars GitHub forks

Compatibility

  Android
  iOS (active issue: iOS support for reflex)

Show some ❤️ and the repo

Why use Reflex?

Reflex Plugin is known for:

Reflex
Fast, performant & compatible
Free & Open-source
Production ready
Make App Reactive

Features

All the features listed below can be performed at the runtime.

  Get Notification Stream
  Read Notification
  Reply From Notification
  Auto Reply

Demo

Quick Start

Step 1: Include plugin to your project

dependencies:
  reflex: <latest version>

Run pub get and get packages.

Step 2: Add Service in AndroidManifest.xml

Add the following service inside the application tag of AndroidManifest.xml.

    ...
    <service
        android:label="notifications"
        android:name="com.devsonflutter.reflex.notification.NotificationListener"
        android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
        <intent-filter>
            <action android:name="android.service.notification.NotificationListenerService" />
        </intent-filter>
    </service>
</application>

Android 12+ Compatibility Add android:exported="true" field in the service tag to make it compatible with Android 12+.

    ...
    <service
        android:label="notifications"
        android:name="com.devsonflutter.reflex.notification.NotificationListener"
        android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
        android:exported="true">
        <intent-filter>
            <action android:name="android.service.notification.NotificationListenerService" />
        </intent-filter>
    </service>
</application>

Step 3: Instantiate Reflex

Reflex must only be instantiated only once.

Reflex reflex = Reflex();

Example

Go to example section in pub.dev to see the full example code.

In GitHub, head over to example/lib/main.dart to see the full example code.

Import

This single import is enough for using reflex.

import 'package:reflex/reflex.dart';

Listen & Reply

StreamSubscription<ReflexEvent>? _subscription;
final List<ReflexEvent> _notificationLogs = [];
final List<ReflexEvent> _autoReplyLogs = [];
bool isListening = false;

Reflex reflex = Reflex(
  debug: true,
  packageNameList: ["com.whatsapp", "com.tyup"],
  packageNameExceptionList: ["com.android.systemui"],
  autoReply: AutoReply(
    packageNameList: ["com.whatsapp"],
    message: "[Reflex] This is an automated reply.",
  ),
);

@override
void initState() {
  super.initState();
  initPlatformState();
}

Future<void> initPlatformState() async {
  startListening();
}

void onData(ReflexEvent event) {
  setState(() {
    if (event.type == ReflexEventType.notification) {
      _notificationLogs.add(event);
    } else if (event.type == ReflexEventType.reply) {
      _autoReplyLogs.add(event);
    }
  });
  debugPrint(event.toString());
}

void startListening() {
  try {
    _subscription = reflex.notificationStream!.listen(onData);
    setState(() {
      isListening = true;
    });
  } on ReflexException catch (exception) {
    debugPrint(exception.toString());
  }
}

void stopListening() {
  _subscription?.cancel();
  setState(() => isListening = false);
}

Quick Guide

A quick guide to Flutter Reflex plugin!

Debugging

Debugging allows you to debug the plugin's functionality, logs are shown in the console.

By default debug logging is enabled. You can configure it using the debug field in the Reflex class.

Reflex reflex = Reflex(
  debug: false,
);

Listen notification permission

See if listening notification permission has been granted or not.

bool isPermissionGranted = await Reflex.isPermissionGranted;

Request notification listening permission

Use the function to grant notification listening permission.

await Reflex.requestPermission();

Notification Stream

Use the reflex object to get a notification stream to listen to notifications in your flutter application.

StreamSubscription<ReflexEvent>? _subscription;
_subscription = reflex.notificationStream!.listen((event) {
  // Application Logic
});

The stream is subscribed for ReflexEvent whenever a notification is received.

Reflex Event

The incoming reflex event contains:

  • type: ReflexEventType.notification whenever a notification is received to flutter application, and ReflexEventType.reply whenever an automated reply is sent.

  • packageName: Application's package name from which notifications are received and reply are sent.

  • title: Notification title

  • message: Message contained in the notification and while sending reply.

  • timestamp: Timestamp of the notification received and reply sent.

Listen notification from specific apps

Specify list of package names to listen to notifications from those applications.

If packageNameList: null plugin will listen to notifications from all packages.

Reflex reflex = Reflex(
  debug: true,
  packageNameList: ["com.whatsapp", "com.facebook"],
);

Avoid notification from specific apps

Specify package name exception list to avoid listening notifications from those applications.

If packageNameExceptionList: null, the plugin will listen to notifications for packageNameList if not null.

Reflex reflex = Reflex(
  debug: true,
  packageNameExceptionList: ["com.whatsapp"],
);

Auto Reply

Send an automated reply while listening notification.

AutoReply autoReply = AutoReply(
  message: "[Reflex] This is an automated reply.",
),

Auto reply specific apps

Specify packageNameList in AutoReply to reply to specific applications.

AutoReply autoReply = AutoReply(
  packageNameList: ["com.whatsapp"],
  message: "[Reflex] This is an automated reply.",
),

The AutoReply object is used by the Reflex's autoReply field to automatically reply to applications.

Reflex reflex = Reflex(
  debug: true,
  packageNameList: ["com.whatsapp", "com.tyup"],
  packageNameExceptionList: ["com.miui.securitycenter"],
  autoReply: AutoReply(
    packageNameList: ["com.whatsapp"],
    message: "[Reflex] This is an automated reply.",
  ),
);

If the autoReply field is null in Reflex class, Auto reply feature will be disabled.

Ambiguity

A ReflexException will be thrown if,

  • Reflex's packageNameList and packageNameExceptionList contains any similar package name.

  • any package name in AutoReply's packageNameList is contained in Reflex's packageNameExceptionList.

Project Created & Maintained By

Divyanshu Shekhar

GitHub followers

Subham Praharaj

GitHub followers

Contributions

Contributions are welcomed!

If you feel that a hook is missing, feel free to open a pull-request.

For a custom-hook to be merged, you will need to do the following:

  • Describe the use-case.

  • Open an issue explaining why we need this hook, how to use it, ... This is important as a hook will not get merged if the hook doens't appeal to a large number of people.

  • If your hook is rejected, don't worry! A rejection doesn't mean that it won't be merged later in the future if more people shows an interest in it. In the mean-time, feel free to publish your hook as a package on https://pub.dev.

  • A hook will not be merged unles fully tested, to avoid breaking it inadvertendly in the future.

Stargazers

Stargazers repo roster for @DevsOnFlutter/reflex

Forkers

Forkers repo roster for @DevsOnFlutter/reflex

Copyright & License

Code and documentation Copyright (c) 2021 Divyanshu Shekhar. Code released under the BSD 3-Clause License.

You might also like...

Minecraft Hug Plugin

Hug Sometimes virtual hugs are better than IRL hugs because you don't actually have to touch anyone. Hug makes it possible to hug another player on th

Sep 7, 2022

GodType is a very simple Bukkit plugin to allow the console (or a player) to chat as a defined name.

GodType GodType is a very simple Bukkit plugin to allow the console (or a player) to chat as a defined name. Config A config.yml file will be created

Dec 24, 2021

A simple plugin to load behavior packs from the 'behavior_packs' folder.

Behaviour Pack Loader for Nukkit A simple plugin to load behavior packs from the behavior_packs folder. If you found any bugs or have any suggestions,

Dec 7, 2022

This is a plugin for Minecraft Server (Spigot API) introduces a sector system which connects a single world across multiple servers.

OpenSourceSectors 😎 🗒️ This is a plugin for Minecraft Server (Spigot API) introduces a sector system which connects a single world across multiple s

Dec 28, 2022

Minecraft configurable plugin , which sends messages the first time a player logs into the server or the next time they log in.

JoinMessages Minecraft configurable plugin , which sends messages the first time a player logs into the server or the next time they log in or leave.

Aug 30, 2022

The IK Analysis plugin integrates Lucene IK analyzer into elasticsearch, support customized dictionary.

IK Analysis for Elasticsearch The IK Analysis plugin integrates Lucene IK analyzer (http://code.google.com/p/ik-analyzer/) into elasticsearch, support

Jan 5, 2023

Log4j2Scan - Log4j2 RCE Passive Scanner plugin for BurpSuite

Log4j2Scan - Log4j2 RCE Passive Scanner plugin for BurpSuite

Log4j2Scan This tool is only for learning, research and self-examination. It should not be used for illegal purposes. All risks arising from the use o

Jan 6, 2023

HubCore - Lobby Plugin for Nukkit with Server Selector, Gadgets, and Friends , Parties!

HubCore HubCore is an in-Development Lobby Plugin for Nukkit and PowerNukkit supporting API Versions through 1.0.9 to 1.0.13 It is highly configurable

Jan 4, 2022

A Jenkins plugin for inserting the commits changelog into the jenkins build environment.

commits-changelog-env-plugin A Jenkins plugin for inserting the commits changelog into the jenkins build environment. Jenkins插件, 在构建时通过将提交的更新列表插入 Jenk

Feb 16, 2022
Comments
  • iOS Implementation required!

    iOS Implementation required!

    • Listen to all notifications from iOS and send a stream to the flutter side.
    • Functions to check notification listening permission and request permission.
    • Reply to chat notifications
    enhancement help wanted 
    opened by divshekhar 2
  • Impossible to change the AutoReply message

    Impossible to change the AutoReply message

    The autoReply field in the Reflex class is final. And there seems to be no way to change the reply message depending on the received message. Or maybe I'm overlooking a field or funtion to change the message content? It would be nice to have a dynamic reply option. For example: Message received: "hi", auto reply: "hello", later message received: "bye", auto reply: "see ya"

    opened by alexph01 1
  • Add url endpoint for handling custom message

    Add url endpoint for handling custom message

    I have url endpoint that can handling a message and return the message response. can you add something like this

    Reflex reflex = Reflex( debug: true, packageNameList: ["com.whatsapp", "com.tyup"], packageNameExceptionList: ["com.android.systemui"], autoReplyEndpoint: urlEndpoint );

    opened by qolbudr 0
  • AutoReply only to specific messages

    AutoReply only to specific messages

    It would be nice if the AutoReply feature would only trigger on specific messages. If someone starts a conversation with "Hello [...]", it would automatically reply to the person, but not otherwise. That way that person would not receive a message every time he/she writes something.

    opened by alexph01 2
Releases(v0.0.1)
Simple and lightweight application which is checking status of your web services and send a notification if it is down.

rose-uptimer Simple and lightweight application which is checking status of your web services and send a notification if it is down. Example configura

RoseSapphire 3 Sep 25, 2022
COMPortNotifier - Smol utility to send you a notification every time you connect, or disconnect a COM port.

COMPortNotifier A smol utility that sends you a notification every time a COM port is connected, or disconnected on your computer. Useful for electric

Matt Foulks 1 Sep 7, 2022
NFT sales tracking on the secondary market, on the Songbird network and notification via a Discord bot

SgbNftMarketDiscordBot Fork this project for any other chain using Ethereum Virtual Machine (EVM) like ETH, FLR, BSC etc If you like the project or fi

null 4 Jan 9, 2023
Excel utility for Java to read and write data in declarative way.

Data Excel Exporter A Java wrapper using Apache POI to read and write Excel file in declarative fashion. Installation ExcelUtil is using Apache POI ve

null 27 Oct 16, 2022
A library to create, read and validate ZUGFeRD compliant invoices. Available for Java and .NET

Konik ZUGFeRD Library Is an easy to use open source implementation of the ZUGFeRD data model including various enhancements. Features Easy and underst

Konik 42 Dec 20, 2022
Generate and read big Excel files quickly

fastexcel fastexcel-writer There are not many alternatives when you have to generate xlsx Excel workbooks in Java. The most popular one (Apache POI) i

Cegid Conciliator 449 Jan 1, 2023
Library that makes it possible to read, edit and write CSV files

AdaptiveTableLayout Welcome the new CSV Library AdaptiveTableLayout for Android by Cleveroad Pay your attention to our new library that makes it possi

Cleveroad 1.9k Jan 6, 2023
trying to create a plugin using the spigot api! this plugin will be responsible for delivering the products according to the settings!

KettraShop "simples plugin de ativação de produtos da loja, dentro do Minecraft" ⚙️ Configurações caso você não tenha uma loja virtual para seu servid

SEBASTIAN JN ฅ^•ﻌ•^ฅ 4 Nov 2, 2022
FactionRanking is a plugin that allows server administrators to put factions in competition in different rankings

Description FactionRanking is a plugin that allows server administrators to put factions in competition in different rankings (working for 1.7 and hig

nz 8 Dec 22, 2022
An open source Minecraft plugin that allows operators to control who has access to the nether.

Nether Access Controller Description Nether Access Controller is a Minecraft plugin that allows operators to control access to the nether. It is essen

Daniel Stephenson 2 Feb 12, 2022