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

Commit

Permalink
🐧 Fix Android O channel confusing name/description
Browse files Browse the repository at this point in the history
  • Loading branch information
camillebeaumont committed Jan 11, 2018
1 parent f6e0dcc commit 24d8267
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,13 @@ PushNotification.createChannel(() => {
console.log('error');
}, {
id: "testchannel1",
description: "My first test channel",
name: "First channel",
description: "This is my very first notification channel",
importance: 3
});
```

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.
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.

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

Expand Down
1 change: 1 addition & 0 deletions src/android/com/adobe/phonegap/push/PushConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public interface PushConstants {
public static final String DEFAULT_CHANNEL_ID = "PushPluginChannel";
public static final String CHANNELS = "channels";
public static final String CHANNEL_ID = "id";
public static final String CHANNEL_NAME = "name";
public static final String CHANNEL_DESCRIPTION = "description";
public static final String CHANNEL_IMPORTANCE = "importance";
public static final String CHANNEL_LIGHT_COLOR = "lightColor";
Expand Down
8 changes: 7 additions & 1 deletion src/android/com/adobe/phonegap/push/PushPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ private JSONArray listChannels() throws JSONException {
for (NotificationChannel notificationChannel : notificationChannels) {
JSONObject channel = new JSONObject();
channel.put(CHANNEL_ID, notificationChannel.getId());
channel.put(CHANNEL_NAME, notificationChannel.getName());
channel.put(CHANNEL_DESCRIPTION, notificationChannel.getDescription());
channels.put(channel);
}
Expand All @@ -93,9 +94,14 @@ private void createChannel(JSONObject channel) throws JSONException {

String packageName = getApplicationContext().getPackageName();
NotificationChannel mChannel = new NotificationChannel(channel.getString(CHANNEL_ID),
channel.optString(CHANNEL_DESCRIPTION, ""),
channel.optString(CHANNEL_NAME, ""),
channel.optInt(CHANNEL_IMPORTANCE, NotificationManager.IMPORTANCE_DEFAULT));

String desc = channel.optString(CHANNEL_DESCRIPTION, "");
if(desc != null && !desc.isEmpty()) {
mChannel.setDescription(desc);
}

int lightColor = channel.optInt(CHANNEL_LIGHT_COLOR, -1);
if (lightColor != -1) {
mChannel.setLightColor(lightColor);
Expand Down
2 changes: 1 addition & 1 deletion src/js/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PushNotification {
this.handlers = {
registration: [],
notification: [],
error: [],
error: []
};

// require options parameter
Expand Down

0 comments on commit 24d8267

Please sign in to comment.