chemerisuk / cordova-plugin-firebase-messaging

Cordova plugin for Firebase Cloud Messaging
MIT License
164 stars 159 forks source link

Added support for notification channels #224

Open grumpygary opened 1 year ago

grumpygary commented 1 year ago

This is my first PR ever, so I apologize if I got it wrong.

I've brought the Android 6.x notification channel implementations forward to 7.x. That said, you still create a default channel called "Firebase" that would be nice to be able to skip based on some sort of config.

Anyway, I hope you find this useful.

-Gary

fredriksthlm commented 1 year ago

That said, you still create a default channel called "Firebase" that would be nice to be able to skip based on some sort of config.

If you don't want the Firebase channel you can comment out the below (FirebaseMessagingPluginService.java, line 57)

// On Android O or greater we need to create a new notification channel
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationChannel defaultChannel = notificationManager.getNotificationChannel(defaultNotificationChannel);
            if (defaultChannel == null) {
                notificationManager.createNotificationChannel(
                        new NotificationChannel(defaultNotificationChannel, "Firebase", NotificationManager.IMPORTANCE_HIGH));
            }
        }
grumpygary commented 1 year ago

That said, you still create a default channel called "Firebase" that would be nice to be able to skip based on some sort of config.

If you don't want the Firebase channel you can comment out the below (FirebaseMessagingPluginService.java, line 57)

// On Android O or greater we need to create a new notification channel
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationChannel defaultChannel = notificationManager.getNotificationChannel(defaultNotificationChannel);
            if (defaultChannel == null) {
                notificationManager.createNotificationChannel(
                        new NotificationChannel(defaultNotificationChannel, "Firebase", NotificationManager.IMPORTANCE_HIGH));
            }
        }

Thanks. I have a version where I did that. I mentioned it above b/c it would be nice to have the ability to turn it off via a config.xml setting.