-
Notifications
You must be signed in to change notification settings - Fork 670
Description
Feature Request
Plugin
LocalNotifications
Description
I'm trying to control which notification channels are used by our app, so they are all meaningful for our users.
To this end, I created my own default channel for Firebase push notifications (following https://capacitorjs.com/docs/apis/push-notifications#push-notification-channel), with a custom ID & localized name. I'm also targeting that channel for scheduled LocalNotification notifications.
But still, another channel called "Default" would keep appearing after each app open. This is not a meaningful channel name for our users.
I eventually found that LocalNotification creates this channel by default when the plugin loads:
Lines 48 to 52 in 9d20478
| public void load() { | |
| super.load(); | |
| notificationStorage = new NotificationStorage(getContext()); | |
| manager = new LocalNotificationManager(notificationStorage, getActivity(), getContext(), this.bridge.getConfig()); | |
| manager.createNotificationChannel(); |
Lines 103 to 110 in 9d20478
| public void createNotificationChannel() { | |
| // Create the NotificationChannel, but only on API 26+ because | |
| // the NotificationChannel class is new and not in the support library | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
| CharSequence name = "Default"; | |
| String description = "Default"; | |
| int importance = android.app.NotificationManager.IMPORTANCE_DEFAULT; | |
| NotificationChannel channel = new NotificationChannel(DEFAULT_NOTIFICATION_CHANNEL_ID, name, importance); |
Platform(s)
Android
Preferred Solution
I would prefer either one of these solutions:
A. The ability to disable default channel creation in the plugin settings, with a boolean flag.
B. The ability to configure the ID and name of the channel that will be created (and used) by default. In this case I would anyway need to upsert the channel with a localized name using JS code, since the plugin settings are static.
Alternatives
I'm currently deleting the default channel with JS code once my app opens, after every app open. It's a little messy, but it works.
What makes this workaround extra unappealing, is that Android might show a information box on the notification channel settings page that mentions: "1 category deleted".