Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default notification channel for foreground push notifications #1368

Closed
nip3o opened this issue Jan 9, 2023 · 2 comments · Fixed by #1657
Closed

Use default notification channel for foreground push notifications #1368

nip3o opened this issue Jan 9, 2023 · 2 comments · Fixed by #1657

Comments

@nip3o
Copy link

nip3o commented Jan 9, 2023

Feature Request

Plugin

"@capacitor/push-notifications": "4.1.2",

Description

If presentationOptions are given in the capacitor config, the push notification plugin automatically creates a notification channel to use for those foreground notifications, with a hard-coded name and description ("Push Notifications Foreground" / "Push notifications in foreground"). This is quite unexpected, especially if the app is internationalized and/or specifies its own channels.

Platform(s)

Android

Preferred Solution

Push notifications in foreground should hade the same behavior as other push notifications, and use the "regular" default notification channel if no channel is specified on the notification.

An issue with this solution is however that a notification channel might be needed in order to use the "sound" option for presentationOptions.

Alternatives

An alternative solution would be to make it possible to specify a channelId to use for this in settings and let the user be responsible for creating the channel themselves if set.

Another option would be to document this behavior so that developers at least knows that this is happening when using presentationOptions and instead handle foreground notifications themselves if they do not want the current behavior.

@RaddishIoW
Copy link

I have completed a PR (#1423) which allows you to:

  1. Specify a manually created channel to post notifications to when they are received in the foreground, or
  2. Specify options for the default foreground channel (e.g. sound), or
  3. Specify that the notification should be posted to the channel for which it was originally intended (i.e. the channel in the notification payload).

This is done through the plugin config, with the default behaviour being the current (post to a special foreground channel created by the plugin).

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 22, 2023

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.