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

Commit 24d8267

Browse files
🐧 Fix Android O channel confusing name/description
1 parent f6e0dcc commit 24d8267

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

docs/API.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,13 @@ PushNotification.createChannel(() => {
166166
console.log('error');
167167
}, {
168168
id: "testchannel1",
169-
description: "My first test channel",
169+
name: "First channel",
170+
description: "This is my very first notification channel",
170171
importance: 3
171172
});
172173
```
173174

174-
The above will create a channel for your app. You'll need to provide the `id`, `description` and `importance` properties. The importance property goes from 1 = Lowest, 2 = Low, 3 = Normal, 4 = High and 5 = Highest.
175+
The above will create a channel for your app. You'll need to provide the `id`, `name` and `importance` properties, `description` is optional. The importance property goes from 1 = Lowest, 2 = Low, 3 = Normal, 4 = High and 5 = Highest.
175176

176177
## PushNotification.deleteChannel(successHandler, failureHandler, channelId)
177178

src/android/com/adobe/phonegap/push/PushConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public interface PushConstants {
8888
public static final String DEFAULT_CHANNEL_ID = "PushPluginChannel";
8989
public static final String CHANNELS = "channels";
9090
public static final String CHANNEL_ID = "id";
91+
public static final String CHANNEL_NAME = "name";
9192
public static final String CHANNEL_DESCRIPTION = "description";
9293
public static final String CHANNEL_IMPORTANCE = "importance";
9394
public static final String CHANNEL_LIGHT_COLOR = "lightColor";

src/android/com/adobe/phonegap/push/PushPlugin.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ private JSONArray listChannels() throws JSONException {
6767
for (NotificationChannel notificationChannel : notificationChannels) {
6868
JSONObject channel = new JSONObject();
6969
channel.put(CHANNEL_ID, notificationChannel.getId());
70+
channel.put(CHANNEL_NAME, notificationChannel.getName());
7071
channel.put(CHANNEL_DESCRIPTION, notificationChannel.getDescription());
7172
channels.put(channel);
7273
}
@@ -93,9 +94,14 @@ private void createChannel(JSONObject channel) throws JSONException {
9394

9495
String packageName = getApplicationContext().getPackageName();
9596
NotificationChannel mChannel = new NotificationChannel(channel.getString(CHANNEL_ID),
96-
channel.optString(CHANNEL_DESCRIPTION, ""),
97+
channel.optString(CHANNEL_NAME, ""),
9798
channel.optInt(CHANNEL_IMPORTANCE, NotificationManager.IMPORTANCE_DEFAULT));
9899

100+
String desc = channel.optString(CHANNEL_DESCRIPTION, "");
101+
if(desc != null && !desc.isEmpty()) {
102+
mChannel.setDescription(desc);
103+
}
104+
99105
int lightColor = channel.optInt(CHANNEL_LIGHT_COLOR, -1);
100106
if (lightColor != -1) {
101107
mChannel.setLightColor(lightColor);

src/js/push.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class PushNotification {
1818
this.handlers = {
1919
registration: [],
2020
notification: [],
21-
error: [],
21+
error: []
2222
};
2323

2424
// require options parameter

0 commit comments

Comments
 (0)