Skip to content

Commit

Permalink
solved fquirin#1 where notification channel ist not created on schedu…
Browse files Browse the repository at this point in the history
…le new notifications
  • Loading branch information
mariosteinbacher committed Jan 23, 2023
1 parent e1cc6d8 commit d5e5f20
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-local-notification",
"version": "0.10.1",
"version": "0.10.2",
"description": "Schedules and queries for local notifications",
"cordova": {
"id": "cordova-plugin-local-notification",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-local-notification"
version="0.10.1">
version="0.10.2">

<name>LocalNotification</name>

Expand Down
6 changes: 4 additions & 2 deletions src/android/notification/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ public boolean hasPermission() {
* @param receiver Receiver to handle the trigger event.
*/
public Notification schedule(Request request, Class<?> receiver) {
Options options = request.getOptions();
Notification toast = new Notification(context, options);
// Options options = request.getOptions();
JSONObject options = request.getOptions().getDict();
Options options_with_context = new Options(context, options); //needed to create Notification Channel if not exists (AssetUtil.parse)
Notification toast = new Notification(context, options_with_context);

toast.schedule(request, receiver);

Expand Down
6 changes: 3 additions & 3 deletions src/android/notification/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ void schedule(Request request, Class<?> receiver) {
if (date == null)
continue;

//check or create Notification Channel
channelId = options.getChannel();

Intent intent = new Intent(context, receiver)
.setAction(PREF_KEY_ID + request.getIdentifier())
.putExtra(Notification.EXTRA_ID, options.getId())
Expand Down Expand Up @@ -225,6 +222,9 @@ void schedule(Request request, Class<?> receiver) {
int notificationId = options.getId();
PendingIntent pi =
LaunchUtils.getBroadcastPendingIntent(context, intent, notificationId);

//check or create Notification Channel (AssetUtil.parse)
channelId = options.getChannel();

try {
switch (options.getPrio()) {
Expand Down

0 comments on commit d5e5f20

Please sign in to comment.