パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v3.2.0

flutter_notification_channel

Androidで通知チャンネルを設定するためのプラグイン

AndroidiOS
30日間ダウンロード
3900
いいね数
33
Pub ポイント
120

パッケージをインストール

flutter pub add flutter_notification_channel

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

flutter_notification_channel パッケージは、Flutter アプリケーション内で Android デバイスの通知チャンネルを簡単に構成および管理できるようにします。このパッケージは、通知チャンネルを作成・更新・カスタマイズするためのシンプルな API を提供し、Android の通知チャンネル要件に従って通知が適切に分類され、表示されることを保証します。このパッケージは Android と iOS の両方のプラットフォームをサポートしていますが、主な機能は Android のチャンネルベースの通知システムに焦点を当てています。音声、振動、重要度レベルなどの通知動作に対する細かい制御を可能にすることで、ユーザー体験を向上させます。

用途

  • カスタム通知チャンネルの設定
  • 通知の重要度レベルの管理
  • 通知音と振動のカスタマイズ
  • Android 8.0以降の通知要件への準拠を確保する
  • 整理された通知によるユーザーエクスペリエンスの向上

主な機能

  • 通知チャネルを作成するためのシンプルな API
  • Android 8.0以降のチャネル要件に対応
  • クロスプラットフォーム互換性(AndroidおよびiOS)
  • 重要度や音声などの設定可能なチャネルプロパティ
  • 既存の通知システムとの簡単な統合

適している対象

  • 構造化通知管理を必要とするアプリ
  • Android 8.0以降のデバイスをターゲットとする開発者
  • カスタマイズ可能な通知動作が必要なプロジェクト
  • 複数の通知タイプを持つアプリを構築しているチーム
  • プッシュ通知を使用するFlutterアプリ

注意事項

  • 主な機能は Android に限定されています
  • iOS のサポートは限定的です(チャンネル作成なし)
  • プラットフォーム固有のロジックを手動で処理する必要があります
  • 古い Android バージョンでは、基本的な通知には不要です
  • 他の通知プラグインと併用するのが最適です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

flutter_notification_channel

https://pub.dev/packages/flutter_notification_channel

This plugin is made to register notification channels with custom configurations on Android. For more details read this https://developer.android.com/training/notify-user/channels Why is it necessary? E.g. firebase_messaging version 7.0.3 (current) and lower do not allow to set up a notification channel, thus notifications don't play any sounds or do not display on locked screen, or don't bubble and so on. This plugin is made merely for the purpose of creation a notification channel with custom configurations on Android. The channels then can be used along with firebase_messaging.

How to use

Simply call it like this

var result = await FlutterNotificationChannel().registerNotificationChannel(
    description: 'Your channel description',
    id: 'your_channel_id',
    importance: NotificationImportance.IMPORTANCE_HIGH,
    name: 'Your channel name',
    visibility: NotificationVisibility.VISIBILITY_PUBLIC,
    allowBubbles: true,
    enableVibration: true,
    enableSound: true,
    showBadge: true,
);
print(result);

Importance Levels

The plugin supports the following notification importance levels:

  • NotificationImportance.IMPORTANCE_MIN (1): Minimal importance, might not be shown
  • NotificationImportance.IMPORTANCE_LOW (2): Low importance, shows in shade and potentially status bar but not audibly intrusive
  • NotificationImportance.IMPORTANCE_DEFAULT (3): Default importance, shows everywhere and makes noise but doesn't visually intrude
  • NotificationImportance.IMPORTANCE_HIGH (4): Higher importance, shows everywhere, makes noise and peeks, may use full screen intents
  • NotificationImportance.IMPORTANCE_MAX (5): Maximum importance, most intrusive level, should be used sparingly for critical notifications only
Example with Maximum Importance

For critical notifications that require immediate user attention:

var result = await FlutterNotificationChannel().registerNotificationChannel(
    description: 'Critical system alerts',
    id: 'critical_channel_id',
    importance: NotificationImportance.IMPORTANCE_MAX,
    name: 'Critical Alerts',
    visibility: NotificationVisibility.VISIBILITY_PUBLIC,
    allowBubbles: true,
    enableVibration: true,
    enableSound: true,
    showBadge: true,
);

Then, when you send a message to firebase like this, specify your android_channel_id and sound: "default" in order to play a default sound if you set "enableSound" in plugin. If you don't do this, the sound wont play at all on android 9 (I have no idea why)

{
  "notification": {
    "title": "Your message title",
    "body": "Your message body",
    "android_channel_id": "your_channel_id",
    "sound": "default"
  },
  "data": {
    "click_action" : "FLUTTER_NOTIFICATION_CLICK",
  },
  "priority": "high",
  "content_available": true,
  "to": "YOUR_FIREBASE_PUSH_TOKEN_GOES_HERE"
}

カテゴリー

依存関係

依存関係一覧 1 件

  • plugin_platform_interface^2.1.8

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。