From c1c3805cf47c2db75f78314fd57f8a5eaa83e217 Mon Sep 17 00:00:00 2001 From: Kieran David Evans Date: Mon, 19 Mar 2018 17:29:21 +0000 Subject: [PATCH] Fix for required notification channel on Oreo --- plugin.xml | 1 + src/android/FirebasePluginMessagingService.java | 14 +++++++++++++- src/android/cordova-plugin-firebase-strings.xml | 5 +++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/android/cordova-plugin-firebase-strings.xml diff --git a/plugin.xml b/plugin.xml index 56f80c548..0ade7b02c 100644 --- a/plugin.xml +++ b/plugin.xml @@ -48,6 +48,7 @@ xmlns:android="http://schemas.android.com/apk/res/android"> + diff --git a/src/android/FirebasePluginMessagingService.java b/src/android/FirebasePluginMessagingService.java index f67d3c5c4..ccbdab1f5 100755 --- a/src/android/FirebasePluginMessagingService.java +++ b/src/android/FirebasePluginMessagingService.java @@ -1,5 +1,6 @@ package org.apache.cordova.firebase; +import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; @@ -13,6 +14,7 @@ import android.text.TextUtils; import android.content.ContentResolver; +import com.asb360.area.dev.R; import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; @@ -93,8 +95,10 @@ private void sendNotification(String id, String title, String messageBody, Map= android.os.Build.VERSION_CODES.O) { + NotificationChannel channel = new NotificationChannel(channelId, + channelName, + NotificationManager.IMPORTANCE_DEFAULT); + notificationManager.createNotificationChannel(channel); + } + notificationManager.notify(id.hashCode(), notification); } else { bundle.putBoolean("tap", false); diff --git a/src/android/cordova-plugin-firebase-strings.xml b/src/android/cordova-plugin-firebase-strings.xml new file mode 100644 index 000000000..d992bd6a2 --- /dev/null +++ b/src/android/cordova-plugin-firebase-strings.xml @@ -0,0 +1,5 @@ + + + fcm_default_channel + Default +