phonegap / phonegap-plugin-push

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

No Custom Sound #1434

Open ppetree opened 7 years ago

ppetree commented 7 years ago

Expected Behaviour

Play a custom sound (default sounds work just fine).

Actual Behaviour

iOS plays default sound Android does nothing, doesn't even show a received push notification

Reproduce Scenario (including but not limited to)

Steps to Reproduce

See below...

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

iOS 9.3.3 on an iPad3, iPhone 4s, iOS 10.1 on an iPhone 5c Android 4.2.2 on a NextTab (latest version for that device)

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

NextTab

Cordova CLI version and cordova platform version

CLI 6.2.0 for both Android and iOS

Plugin version

1.8.4 (latest version that works with XDK)

Sample Push Data Payload

iOS: Payload to GCM:

{"priority":"high",
  "notification":{"body":"Life threatening emergency; Heart attack",
  "title":"Medical Emergency",
  "vibrate":true,
  "custom_field_1":46,
  "custom_field_2":"2",
  "sound":"eas"},
"registration_ids":["m_zCoZhBNDE:blahblahblah","mvIqmUsmOYk:blahblahblah"]}

iOS Push Payload Received:

{"title":"Medical Emergency",
"sound":"eas",
"additionalData":{"foreground":false,
                  "gcm.message_id":"0:1470426723672831%b7f1dca2b7f1dca2",
                  "gcm.notification.vibrate":"true",
                  "gcm.notification.custom_field_1":"44",
                  "coldstart":false,
                  "gcm.notification.custom_field_2":"2"},
"message":"Life threatening emergency; Heart attack"}

Android fields to GCM:

{"priority":"high",
 "data":
   {"message":"Life threatening emergency; Heart attack",
    "alert":"Medical Emergency",
    "title":"Medical Emergency",
    "category":"Medical Emergency",
    "style":"inbox",
    "vibrate":true,
    "sound":"eas",
    "custom_field_1":46,
    "custom_field_2":"2"},
 "registration_ids":["cW5Z_tJ7qo8:blahblahblah"]}

Android Push Payload:

{"message":"Life threatening emergency; Heart attack",
"additionalData":{"category":"Medical Emergency",
                  "custom_field_1":"44",
                  "collapse_key":"do_not_collapse",
                  "custom_field_2":"2",
                  "style":"inbox",
                  "coldstart":false,
                  "vibrate":"true",
                  "foreground":false},
"sound":"eas",
"title":"Medical Emergency"}

Sound File Types and Locations: iOS:

Payload/AppName/bwerp.caf
Payload/AppName/eas.caf
www/bwerp.wav
www/eas.wav
www/res/bwerp.caf
www/res/eas.caf

Android:

res/raw/bwerp.wav
res/raw/eas.wav
assets/www/bwerp.wav
assets/www/eas.wav

The custom sound files are 16 bit (not sure if mono or stereo or if that matters).

I'm stumped.

macdonst commented 7 years ago

@ppetree when you receive a push on Android what do the logs say. Run adb logcat | grep PushPlugin and send your push message.

Also, did you try a mp3 file? IIRC wav may not be supported on Android.

ppetree commented 7 years ago

.wav is accepted everywhere finer sounds are played... ;-) Seriously, every piece of documentation out there says that .wav will work on both platforms. I can try .mp3 tomorrow.

I had ADB installed on my old laptop (circa phonegap 1.6) but on this new laptop I just have XDK. I can try to download ADB this weekend....

ppetree commented 7 years ago

.mp3 produced no sounds... same results as .wav

aces-tm commented 7 years ago

ppetree, were you able to solve this? Where do you save the file. I am trying with .wav and .caf but it doesn't work. What's your payload? Thanks

ppetree commented 7 years ago

@acessoftware First, ignore all the documentation... when it comes to GCM/FCM it's either wrong, misinformed or there's a secret that the authors are failing to share with us mere mortals.

Second, mine is working on GCM/FCM. I've no clue what other push providers are doing so these instructions really only apply to GCM/FCM.

Third, I wrote a little javascript (here on github) that allows you to take over console.log and output your payload to a div. This is incredibly useful for viewing the various states of the push (you'll see lots of differences between GCM and what the docs say) or doing untethered field debugging.

The Payload: The iOS payload MUST contain the sound file extension, the android does not contain the extension. The iOS payload uses "sound" while android uses "soundname"

If you look inside your .ipa (rename .ipa to zip) your structure looks something like this: Payload/AppName.app/

In the AppName.app folder you'll fine all of your splash screens and icons, you should also find your custom sound files.

My files are .wav, 32 bit stereo, 44100hz and play on both iOS and android devices.

Depending on your build platform on how you get the sound files into that location. I was using XDK (now deprecated) so I built a custom plugin to copy the sound files. If you don't know how to do this, tag me back and I'll post the code.

HTH!

HamzaLJ commented 7 years ago

I am having the same here; however, in my case, the android custom sound works fine. In iOS, it fails.

ppetree commented 7 years ago

If using GCM or fire, try specifying the sound file extension on the iOS push notification (opposite of docs)

Also, the location of the sound files is different than specified in the push docs.

Sent from my iPhone

On Aug 10, 2017, at 7:50 PM, Hamza L notifications@github.com wrote:

I am having the same here; however, in my case, the android custom sound works fine. In iOS, it fails.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

HamzaLJ commented 7 years ago

I am using APNS to send notifications in iOS. The docs say that you need to include the file extension and I already specified it (it didn't work either). However, can you let me know more about the file location ? I put it in the root folder, it didn't worked.

Le 11 août 2017 à 02:21, Phil Petree notifications@github.com a écrit :

If using GCM or fire, try specifying the sound file extension on the iOS push notification (opposite of docs)

Also, the location of the sound files is different than specified in the push docs.

Sent from my iPhone

On Aug 10, 2017, at 7:50 PM, Hamza L notifications@github.com wrote:

I am having the same here; however, in my case, the android custom sound works fine. In iOS, it fails.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.