diff --git a/src/android/com/adobe/phonegap/push/PushConstants.java b/src/android/com/adobe/phonegap/push/PushConstants.java index 9b4656a00..6f8d0b777 100644 --- a/src/android/com/adobe/phonegap/push/PushConstants.java +++ b/src/android/com/adobe/phonegap/push/PushConstants.java @@ -93,6 +93,7 @@ public interface PushConstants { public static final String CHANNEL_ID = "id"; public static final String CHANNEL_DESCRIPTION = "description"; public static final String CHANNEL_IMPORTANCE = "importance"; + public static final String CHANNEL_SOUND_URI = "soundUri"; public static final String CHANNEL_LIGHT_COLOR = "lightColor"; public static final String CHANNEL_VIBRATION = "vibration"; public static final String ANDROID_CHANNEL_ID = "android_channel_id"; @@ -102,4 +103,5 @@ public interface PushConstants { public static final String ONGOING = "ongoing"; public static final String LIST_CHANNELS = "listChannels"; public static final String CLEAR_NOTIFICATION = "clearNotification"; + public static final String OPEN_NOTIFICATIONS_SETTINGS = "openNotificationsSettings"; } diff --git a/src/android/com/adobe/phonegap/push/PushPlugin.java b/src/android/com/adobe/phonegap/push/PushPlugin.java index c1f0a10c6..1a79cb19c 100644 --- a/src/android/com/adobe/phonegap/push/PushPlugin.java +++ b/src/android/com/adobe/phonegap/push/PushPlugin.java @@ -6,12 +6,14 @@ import android.app.NotificationManager; import android.content.ContentResolver; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Resources; import android.media.AudioAttributes; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.provider.Settings; import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationManagerCompat; import android.util.Log; @@ -69,6 +71,8 @@ private JSONArray listChannels() throws JSONException { JSONObject channel = new JSONObject(); channel.put(CHANNEL_ID, notificationChannel.getId()); channel.put(CHANNEL_DESCRIPTION, notificationChannel.getDescription()); + channel.put(CHANNEL_IMPORTANCE, notificationChannel.getImportance()); + channel.put(CHANNEL_SOUND_URI, notificationChannel.getSound()); channels.put(channel); } } @@ -435,6 +439,21 @@ public void run() { } } }); + } else if (OPEN_NOTIFICATIONS_SETTINGS.equals(action)) { + // open notifications settings + cordova.getThreadPool().execute(new Runnable() { + public void run() { + try { + Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS); + intent.putExtra(Settings.EXTRA_APP_PACKAGE, cordova.getContext().getApplicationInfo().packageName); + intent.putExtra(Settings.EXTRA_CHANNEL_ID, data.getString(0)); + cordova.getActivity().getApplicationContext().startActivity(intent); + callbackContext.success(); + } catch (JSONException e) { + callbackContext.error(e.getMessage()); + } + } + }); } else { Log.e(LOG_TAG, "Invalid action : " + action); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION)); diff --git a/src/js/push.js b/src/js/push.js index 81d65d5bb..3d485707c 100644 --- a/src/js/push.js +++ b/src/js/push.js @@ -335,6 +335,10 @@ module.exports = { exec(successCallback, errorCallback, 'PushNotification', 'listChannels', []); }, + openNotificationsSettings: (successCallback, errorCallback, channelId) => { + exec(successCallback, errorCallback, 'PushNotification', 'openNotificationsSettings', [channelId]); + }, + /** * PushNotification Object. * diff --git a/www/push.js b/www/push.js index ac19ed71c..b18a03f6c 100644 --- a/www/push.js +++ b/www/push.js @@ -372,6 +372,9 @@ module.exports = { listChannels: function listChannels(successCallback, errorCallback) { exec(successCallback, errorCallback, 'PushNotification', 'listChannels', []); }, + openNotificationsSettings: function openNotificationsSettings(successCallback, errorCallback, channelId) { + exec(successCallback, errorCallback, 'PushNotification', 'openNotificationsSettings', [channelId]); + }, /** * PushNotification Object.