패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.6.1

notification_permissions

Android 및 iOS에서 알림 권한을 확인하고 요청하는 플러그인

AndroidiOS
30일 다운로드
1.3천
좋아요
117
Pub 점수
120

패키지 설치

flutter pub add notification_permissions

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

notification_permissions 패키지는 Android 및 iOS 플랫폼에서 알림 권한을 확인하고 요청하는 간단한 방법을 제공합니다. 앱은 현재의 권한 상태를 확인하고 사용자에게 알림을 허용하거나 거부하도록 유도할 수 있으며, 플랫폼별 요구 사항을 준수하게 됩니다. 이 플러그인은 가볍고 Flutter 애플리케이션에 원활하게 통합되며, 런타임 검사와 사용자 상호작용 흐름을 모두 지원합니다. 개발자가 알림 접근 권한을 책임감 있게 관리하고, 적절한 시점에 사용자를 권한 요청으로 안내함으로써 사용자 경험을 향상시킵니다.

사용 사례

  • 현재 알림 권한 상태 확인
  • 사용자에게 알림 권한 요청하기
  • 앱 로직에서 권한 응답 처리하기
  • 플랫폼 가이드라인 준수 보장
  • 적시 알림을 통한 사용자 참여도 향상

주요 기능

  • Android 및 iOS용 크로스플랫폼 지원
  • 권한 확인 및 요청을 위한 간단한 API
  • 비동기 권한 처리를 지원합니다
  • 명확한 권한 상태를 제공
  • 필요한 최소한의 보일러플레이트 코드

적합한 대상

  • 푸시 알림이 필요한 앱
  • 권한 안내가 필요한 사용자 중심 앱
  • 개인정보 보호를 고려한 기능을 개발하는 개발자
  • 모바일 플랫폼 둘 다를 대상으로 하는 Flutter 앱
  • 사용자 동의와 투명성을 강조하는 프로젝트

고려 사항

  • 권한 거부 상황을 올바르게 처리해야 합니다
  • 사용자 흐름에 영향을 주는 시스템 대화 상자를 트리거할 수 있습니다
  • 각 플랫폼에서 적절한 앱 구성이 되지 않으면 작동하지 않습니다
  • 알림 권한에만 제한됨(다른 유형은 제외)
  • 운영 체제 수준의 동작으로 인해 실제 장치에서 테스트가 필요합니다

원본 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!

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트