Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

✨ 🐧 Allow implementation of a user invitation to fix settings #2848

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/android/com/adobe/phonegap/push/PushConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
}
19 changes: 19 additions & 0 deletions src/android/com/adobe/phonegap/push/PushPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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));
Expand Down
4 changes: 4 additions & 0 deletions src/js/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ module.exports = {
exec(successCallback, errorCallback, 'PushNotification', 'listChannels', []);
},

openNotificationsSettings: (successCallback, errorCallback, channelId) => {
exec(successCallback, errorCallback, 'PushNotification', 'openNotificationsSettings', [channelId]);
},

/**
* PushNotification Object.
*
Expand Down
3 changes: 3 additions & 0 deletions www/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down