搜尋套件、儲存庫與 APP 分類

reflex 封面
套件詳情v0.0.2

reflex

Flutter 插件,用於讀取通知並自動回覆自訂訊息。

AndroidiOS
近 30 天下載
15
喜歡數
42
Pub 分數
130

安裝套件

flutter pub add reflex

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Reflex 是一個 Flutter 插件,讓應用程式能夠讀取傳入的通知並自動發送自訂回覆。專為 Android 和 iOS 設計,與系統級通知服務整合,以程式化方式監控和回應訊息。適用於聊天機器人、自動化客戶支援或智慧訊息工作流程,Reflex 讓開發者能建構對即時通知作出反應的應用程式。此插件為開源,由 devsonflutter 維護,可透過 pub.dev 簡單整合。支援兩個平台,非常適合跨平台訊息功能增強。

適用情境

  • 自動聊天機器人回覆
  • 智能通知處理
  • 客戶支援自動化
  • 即時訊息監控
  • 跨平台訊息應用

主要特色

  • 讀取傳入的通知
  • 自動回覆自定訊息
  • 支援 Android 和 iOS
  • 開源且由社群驅動
  • 透過 pub.dev 的簡單整合

適合對象

  • 開發聊天機器人
  • 需要自動回應的應用程式
  • 訊息傳遞和支援工具
  • 跨平台通知系統
  • 面向自動化的Flutter專案

使用建議

  • 需要使用者授權通知存取權限
  • 僅限系統通知讀取
  • 可能不適用於所有設備製造商
  • 依賴於平台特定的後台執行
  • 隱私敏感的使用案例需要透明度

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Reflex

Flutter plugin for notification read & reply.

Flutter_Shortcuts

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 :heart: and :star: 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.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。