Skip to content

feat(push-notifications): add app and channel enabled checks - #2602

Open
theartifix wants to merge 1 commit into
ionic-team:mainfrom
theartifix:feat/push-notification-enabled-checks
Open

theartifix wants to merge 1 commit into
ionic-team:mainfrom
theartifix:feat/push-notification-enabled-checks

Conversation

@theartifix

Copy link
Copy Markdown

Apps using push notifications need to know whether the user has disabled notifications for the app or a particular channel.

On Android 12 and below, PushNotifications.checkPermissions() always returns granted. Checking the app-wide notification setting currently requires installing Local Notifications and calling its checkPermissions() method, despite the two methods having the same name. For channels, callers have to use listChannels() and inspect the channel’s importance.

This PR adds:

  • checkAppEnabled() on Android and iOS.
  • checkChannelEnabled({ id }) on Android.
  • An enabled field on channels returned by listChannels().

Both check methods return { value: boolean }. The channel check returns false if the channel is missing or has IMPORTANCE_NONE. It checks the channel’s own setting separately from app-wide and channel-group settings. On iOS, authorized, provisional, and ephemeral authorization count as enabled.

Push Notifications already exposes channel management, so these checks fit alongside the existing APIs and let apps read notification settings without adding another plugin.

Typings and generated docs are updated. There are no new dependencies or changes to permission requests. Channel checks follow the existing behavior: unavailable below Android 8.0 (API 26), and unimplemented on iOS.

Builds, TypeScript checks, ESLint, Prettier, and SwiftLint passed. Three iOS tests passed, along with four Android tests on API 36 with app notifications both enabled and blocked. Two tests also passed on Android 7.1.1 (API 25), covering the app-wide notification check and confirming that channel checks return UNAVAILABLE on older Android versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant