Custom sound not played when push arrives
Asked Answered
D

3

6

I've added a custom sound to my app but it doesn't get played when a push arrives. I've no idea why not, I can't see anything different from what I have done and there are so few steps involved.

1) The sound file is a valid audio file which is audible (I can even click and play it within Xcode).

2) The sound file is present in the app's bundle:

enter image description here

3) The sound file name is specified with the exact name and case in the push payload:

{"aps":{"alert":"Test","badge":0,"sound":"PyngNotification.caf"}}

4) I've tried specifying the name without the extension, just as "PyngNotification".

5) The push arrives and is displayed but the custom sound isn't played.

6) The phone makes the same noise regardless of if the push content contains a sound of "PyngNotification.caf", "default" or "". Its a short buzz type of sound.

7) Sounds are not disabled on the phone, nor for pushes for the app.

8) The app is registering for UIRemoteNotificationTypeSound (if iOS8). (The app displays Sounds as one of the permitted types if viewed via the control panel).

9) I have more than one phone, one with iOS8, one with iOS7. The sounds plays on neither of them.

10) The sound is under 30 seconds.

11) The sound was ma4 and converted to caf using afconvert.

I can't see any steps I've left out, nor anything that is incorrect. Anybody have any ideas?

Denigrate answered 24/2, 2015 at 5:34 Comment(4)
Can you manually play the same sound as described here? I have the exact same setup as you, and my custom sound plays just fine on iOS 8.3Vadnais
I also have the same configuration and using same as @black_stallion mention, but for me it work on IOS 7 but not on IOS 8Underwaist
I have the same issue!! working on ios 9 device every time but not ios 8 device. What's crazy is I got it to work 1 time on ios 8 device. But on subsequent builds with different sounds it's not working.Bulbiferous
Thanks copy bundled resources helped meReact
T
1

Tap on the sound file that isn't working in Xcode. Look at the file inspector on the right and make sure the "Target Membership" option is checked.

Toot answered 3/10, 2017 at 17:44 Comment(0)
D
0

The steps which you provided are pretty much everything I had, except background modes setup. I had to put check on the "Audio, Airplay, and Picture in Picture" mode from the Capabilities > Background Modes. Hope it helps.

Dominican answered 24/5, 2019 at 13:2 Comment(0)
W
-3

Acc. to Apple's Documentation https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW6

Preparing Custom Alert Sounds

For remote notifications in iOS, you can specify a custom sound that iOS plays when it presents a local or remote notification for an app. The sound files must be in the main bundle of the client app.

Custom alert sounds are played by the iOS system-sound facility, so they must be in one of the following audio data formats:

Linear PCM
MA4 (IMA/ADPCM)
µLaw
aLaw

You can package the audio data in an aiff, wav, or caf file. Then, in Xcode, add the sound file to your project as a nonlocalized resource of the app bundle.

You may use the afconvert tool to convert sounds. For example, to convert the 16-bit linear PCM system sound Submarine.aiff to IMA4 audio in a CAF file, use the following command in the Terminal app:

afconvert /System/Library/Sounds/Submarine.aiff ~/Desktop/sub.caf -d ima4 -f caff -v

You can inspect a sound to determine its data format by opening it in QuickTime Player and choosing Show Movie Inspector from the Movie menu.

Custom sounds must be under 30 seconds when played. If a custom sound is over that limit, the default system sound is played instead.

Wolfy answered 24/2, 2015 at 5:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.