katzer / cordova-plugin-local-notifications

Cordova Local-Notification Plugin
Apache License 2.0
2.56k stars 1.75k forks source link

foreground : true, is Not Working #1855

Open hanoj-budime opened 4 years ago

hanoj-budime commented 4 years ago

WARNING: IF YOU IGNORE THIS TEMPLATE, WE'LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!

Provide a general summary of the issue.

Your Environment

Expected Behavior

this.localNotifications.schedule({
          foreground : true,
          sound: this.platform.is("android") ? 'file://sound.mp3': 'file://beep.caf',
          id: 2,
          text: `your back`,
          data: { secret: 'secret' },
          priority: 1
        });

Tell us what should happen

Just add foreground:true in notification trigger call, and your notification will show up in the foreground, just like Whatsapp !

Actual Behavior

this.localNotifications.schedule({
          foreground : true,  //not working 
          sound: this.platform.is("android") ? 'file://sound.mp3': 'file://beep.caf',
          id: 2,
          text: `your back`,
          data: { secret: 'secret' },
          priority: 1
        });

Tell us what happens instead

foreground:true in notification not working

hanoj-budime commented 4 years ago

please some one help me...!

gwynjudd commented 4 years ago

Probably related to the fix in this PR

https://github.com/katzer/cordova-plugin-local-notifications/pull/1696

Arieru commented 4 years ago

Probably related to the fix in this PR

1696

How do I apply this fix in Ionic 4?

hanoj-budime commented 4 years ago

Probably related to the fix in this PR

1696

PR means ?

Arieru commented 4 years ago

PR means ?

Pull Request

hanoj-budime commented 4 years ago

can any one help ?

gwynjudd commented 4 years ago

@HanojHanu if you are seeing a problem with android 8 or above, it is because of the change to do with channels (https://developer.android.com/guide/topics/ui/notifiers/notifications#ManageChannels). The plugin has got some support for channels, but the default channel it uses is not configured to use heads up notifications.

Possible solutions:

  1. train your users to configure the default channel to display the notifications heads up
  2. use the PR #1696 - with this PR, you can configure the channel at the time you create the notification for things like sound, heads up behaviour (pop on screen) and so on
  3. create a channel yourself which is configured to use heads up behaviour, and use the name of that channel as the "channel" property in the options when you schedule the notification

I don't know which solution above is going to work for you