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

パッケージ詳細v0.6.1

notification_permissions

Android および iOS で通知の権限を確認および要求するためのプラグイン

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

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

flutter pub add notification_permissions

パッケージ概要

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

notification_permissions パッケージは、Android および iOS プラットフォーム上で通知の権限を確認および要求する簡単な方法を提供します。アプリが現在の権限状態を判断し、ユーザーに通知の許可または拒否を求める機能を備えており、プラットフォーム固有の要件に準拠しています。このプラグインは軽量で、Flutter アプリケーションへのシームレスな統合を可能にし、実行時チェックとユーザーインタラクションフローをサポートしています。開発者が通知アクセスを責任を持って管理し、適切なタイミングでユーザーに権限リクエストをガイドすることで、ユーザー体験を向上させます。

用途

  • 現在の通知許可状態を確認しています
  • ユーザーに通知の権限をリクエストする
  • アプリケーションロジックで権限の応答を処理する
  • プラットフォームのガイドラインに準拠することを保証する
  • タイムリーな通知を通じたユーザー参加の向上

主な機能

  • Android および iOS 用のクロスプラットフォーム対応
  • 権限の確認および要求用のシンプルな API
  • 非同期の権限処理をサポートしています
  • 明確な権限ステータス状態を提供
  • 必要な最小限のボイラープレートコード

適している対象

  • プッシュ通知を必要とするアプリ
  • 権限のガイドラインが必要なユーザー向けアプリ
  • プライバシーに配慮した機能を開発する開発者
  • 両方のモバイルプラットフォーム向けのFlutterアプリ
  • ユーザーの同意と透明性を重視するプロジェクト

注意事項

  • 権限拒否のシナリオを適切に処理する必要があります
  • ユーザーのフローに影響を与えるシステムダイアログをトリガーする可能性があります
  • 各プラットフォームで適切なアプリ設定が行われていないと動作しません
  • 通知の権限のみに制限される(他の種類は除く)
  • OSレベルの動作のため、実機でのテストが必要です

元の README

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

Flutter Notification Permissions

Package to check for and ask for Notification Permissions on iOS and Android.

Checking Notification Permission Status

Future<PermissionStatus> permissionStatus =
    NotificationPermissions.getNotificationPermissionStatus();

This method will return an enum with the following values:

enum PermissionStatus {
  provisional, // iOS Only
	granted,
	unknown,
	denied
}

In iOS, a permission is unknown when the user hasn’t accepted or refuse the notification permissions. In Android this state will never occur, since the permission will be granted by default and it will be denied if the user goes to the app settings and turns off notifications for the app. The provisional status will also offer the same behavior.

Requesting Notification Permissions

If the PermissionStatus is denied or unknown, we can ask the user for the Permissions:

Future<PermissionStatus> permissionStatus = NotificationPermissions.requestNotificationPermissions({NotificationSettingsIos iosSettings, bool openSettings});

On Android, if the permission is denied, this method will open the app settings.

In iOS, if the permission is unknown or provisional, it will show an alert window asking the user for the permission. On the other hand, if the permission is denied it has the same behaviour as Android, opening the app settings. Also in iOS if you set openSettings to false settings window won't be opened. You will get denied status. NotificationPermissions.requestNotificationPermissions returns status after user select answer from native permission popup.

Note: if the permission is granted, this method will not do anything.

iOS Error: Swift.h not found

If your project is in Objective-C, you will have to do the changes referenced in this SO post in order to solve the issue:

'notification_permissions/notification_permissions-Swift.h' file not found
    #import <notification_permissions/notification_permissions-Swift.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.

Add use_frameworks! in target Runner in your (YOUR_PROJECT)/ios/Podfile

target 'Runner' do
  use_frameworks! # Add here

Special Thanks

Special thanks to fedecastelli for helping me in the Swift Code!

カテゴリー

ソースリポジトリ

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