feat(push-notifications): add app and channel enabled checks - #2602
Open
theartifix wants to merge 1 commit into
Open
theartifix wants to merge 1 commit into
theartifix wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 returnsgranted. Checking the app-wide notification setting currently requires installing Local Notifications and calling itscheckPermissions()method, despite the two methods having the same name. For channels, callers have to uselistChannels()and inspect the channel’s importance.This PR adds:
checkAppEnabled()on Android and iOS.checkChannelEnabled({ id })on Android.enabledfield on channels returned bylistChannels().Both check methods return
{ value: boolean }. The channel check returnsfalseif the channel is missing or hasIMPORTANCE_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
UNAVAILABLEon older Android versions.