Meteor-Community-Packages / Meteor-Community-Packages/raix-push

Notification Sounds do not work on Android in push 3.0

Open
#156 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
505
Forks
191
PR merge metrics
No merged PRs in 30d

Description

After a day of testing, and looking through the code, I don't think this works on Android:

Here is the documentation from the [Cordova Plugin](https://github.com/phonegap/phonegap-plugin-push#sound) used by this Meteor package.

```
In order for your your notification to play a custom sound you will need to add the files to your Android project's res/raw directory. Then send the follow JSON from GCM:

{
title:"Sound Test",
message: "Loaded res/raw",
soundname: "test"
}
Note: when you specify the custom sound file name omit the file's extension.
```

Here is where raix:push [wraps and sends the notification](https://github.com/raix/push/blob/c1602dddd9c159d4c8aeb84e53d4118b805f354c/lib/server/push.api.js#L276):

```
if (typeof notification.sound !== 'undefined') {
data.soundname = notification.sound;
}
```

Here is how it's [documented to work](https://github.com/raix/push/blob/1c2e6bcdd62707e800e5dbb34b457e7fbb558fd8/docs/BASIC.md#L62):

``` js
Push.send({
from: 'Test',
title: 'Hello',
text: 'World',
badge: 12,
// sound: fileInPublicFolder
query: {
userId: 'xxxxxxxxxxxx'
}
});
```

All of which don't make sense when put together. It may work on iOS, but on Android, I'm calling it out as broken. **If you've used this on Android, I'd love to know how you got notification sounds to work.**

I'm a newb at Cordova, but from the docs, these would be the steps:

From the cordova plugin docs:

1) In order for your your notification to play a custom sound you will need to add the files to your Android project's `res/raw` directory.
2) Send the notification live above (w/o the file extension)

I don't know how to do 1)

Would love to be wrong about it not working :-)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/server/push.api.js around the notification.sound handling and compare it with the Android sound requirements in the linked Cordova plugin documentation. Review docs/BASIC.md and verify how the sound file is expected to reach Android's res/raw directory and how its name is sent; done means the documented flow works for Android or the limitation is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.