Cordova-plugin-local-notifications: Notification not show on head-up

Created on 29 Apr 2018  路  10Comments  路  Source: katzer/cordova-plugin-local-notifications

Provide a general summary of the issue.

Your Environment

  • Plugin version:^0.9.0-beta.2
  • Platform:Android
  • OS version:Windows 10 64 bit
  • Cordova version (cordova -v): 8.0.0
  • Cordova platform version (cordova platform ls): Android 7.0
  • Ionic Version (if using Ionic): 3.1.9

Expected Behavior

Show Notification on head-up on adnroid device

Actual Behavior

it;s not show popup on header of device, it just show small icon for notification on top left of device

Steps to Reproduce

this is my code

 this.localNotifications.schedule({
  id:1,
  text: 'Delayed ILocalNotification',
  trigger: {at: new Date(new Date().getTime() + 3600)},
  led: 'FF0000',
  priority:1,
  sound: 'file://assets/sound/sound1.mp3' });

Context

I already tried to different on device, it result not different

Most helpful comment

Just tested it on beta 3. In order for heads-up to work, it would appear that these needed to be true:

  • foreground: true
  • priority: 1 (or 2)
  • sound: either true, or a path that correctly resolves to a playable file. In your case, I am not sure if sound1.mp3 exists.

tested all variations of code and parameters, read through all posts here.
no, head-up display of notifications definitely does not work with local.notifications beta.3 (Android 8.1.0)

All 10 comments

Just tested it on beta 3. In order for heads-up to work, it would appear that these needed to be true:

  • foreground: true
  • priority: 1 (or 2)
  • sound: either true, or a path that correctly resolves to a playable file. In your case, I am not sure if sound1.mp3 exists.

foreground property is not supported on this version : ^0.9.0-beta.2

@himalayaahuja

It's not clear what you are trying to do. You are also using an old version of the code.

Create a new issue rather than simply adding things onto this one.

Just tested it on beta 3. In order for heads-up to work, it would appear that these needed to be true:

  • foreground: true
  • priority: 1 (or 2)
  • sound: either true, or a path that correctly resolves to a playable file. In your case, I am not sure if sound1.mp3 exists.

tested all variations of code and parameters, read through all posts here.
no, head-up display of notifications definitely does not work with local.notifications beta.3 (Android 8.1.0)

I'm using the latest Beta, I've tried Beta 2 and 3 and it appears not to work, my notifications:

cordova.plugins.notification.local.schedule({
        title: 'Test Notification',
        text: 'test',
        lockscreen: true,
        priority: 1,
        sound: true,
        foreground: true
      });

"cordova-plugin-local-notification": "0.9.0-beta.3"

"phonegap-plugin-push": "^2.2.3"

this.localNotifications.schedule({
silent: false,
id: 1,
title: "Cashberry",
text: notification.message,
led: "FF0000",
sound: "default",
priority: 2,
foreground: true
});

this issue is still persistent. It should have been resolved by now. Please help out if anyone of you has found the solution.

on Android 8+, the priority is determine by channel importance

https://developer.android.com/guide/topics/ui/notifiers/notifications#importance

Last item on Android 8 changes
https://developer.android.com/guide/topics/ui/notifiers/notifications#android_80_api_level_26

From what I can see, the issue is

In Manager.java file
`
private void createDefaultChannel() {
NotificationManager mgr = getNotMgr();

    if (SDK_INT < O)
        return;

    NotificationChannel channel = mgr.getNotificationChannel(CHANNEL_ID);

    if (channel != null)
        return;

    channel = new NotificationChannel(
            CHANNEL_ID, CHANNEL_NAME, IMPORTANCE_DEFAULT);

    mgr.createNotificationChannel(channel);
}

`

@8bhsolutions I think you're right. To test this out, I changed the "IMPORTANCE_DEFAULT" to "IMPORTANCE_HIGH", at which time the notifications were displayed as headsup. This is on Android 9 and 10. The priority, sound, vibrate and foreground all had no effect.

@8bhsolutions did you try this PR #1696

Nope.
I found the cause of the issue, as noted in my earlier comment.
I don't know the plugin well enough to implement a generic fix.

Was this page helpful?
0 / 5 - 0 ratings