phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.91k forks source link

Android does not play notification sound when 'notification' key is not present. #2833

Open sjregan opened 5 years ago

sjregan commented 5 years ago

Expected Behaviour

When you define a notification like this:

var content = {
  priority: 'normal',
  data: {
    title: 'A short string describing the purpose of the notification',
    message: 'The text of the alert message',
    sound: 'default'
  }
};

The default notification sound should play when the notification is received.

Actual Behaviour

The notification is silent. The notification can be made to play be using:

var content = {
  priority: 'normal',
  data: {
    title: 'A short string describing the purpose of the notification',
    message: 'The text of the alert message',
    sound: 'default'
  },
  notification: {
    title: 'A short string describing the purpose of the notification',
    message: 'The text of the alert message',
    sound: 'default'
  }
};

However background notification handlers are not called when notification is tapped.

So the choice is to either have background notification handlers called properly, or sound. Cannot have both.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

  1. Register device for push notifications
  2. Send push notification to device with JSON structures above.

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Android 9.0

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Google

Cordova CLI version and cordova platform version

Cordova version 8.1.2 (cordova-lib@8.1.1) Cordova Android Platform version 7.1.4

Plugin version

phonegap-plugin-push 2.2.3 "PushPlugin"

RaschidJFR commented 5 years ago

Same story here. It seemed to work yesterday and suddenly I can't get the notification event to fire, not even in foreground. The code has not changed, as I'm trying the same commit, but maybe something in the config (ignored by the repo) changed and it's preventing this from working again... so frustrating

lucasdavila commented 4 years ago

Same here

lucasdavila commented 4 years ago

In my case, if I include the notification key, then the sound works, but the notification icon on the lock screen breaks (show only a circle).