Custom notification sound no longer working - ios

I have a Windows service which will send notifications to our iOS app using Apple's push notification service. We were using a custom notification sound which was playing when the notification appeared on the device. Last week after the iOS 10.3.3 update was released, we've found that the custom sound is no longer being played. This is the message we're sending to APS:
{
{
"aps": {
{
"alert": "Alert message",
"badge": 5,
"sound": "mysound.mp3"
}
},
"acme1": "bar",
"acme2": 42
}
}
Our app has not changed, and the custom sound is no longer playing even on devices which have not yet updated to iOS 10.3.3, including devices that can't update past iOS 9.
I'm not exactly sure were to start looking to diagnose the issue; the mobile app is built using Cordova.

I'm surprised it ever worked at all with the mp3 file type.
According to the docs:
You can package the audio data in an aiff, wav, or caf file. Because they are played by the system-sound facility, custom sounds must be in one of the following audio data formats:
Linear
PCM
MA4 (IMA/ADPCM)
µLaw
aLaw
Try converting it to one of the supported formats and packages and it should start working again. See the docs for details on how to do that.

iOS Notifcation custom sound is worked (When app in Foreground,Background,and Terminated)
Local and remote notifications can specify custom alert sounds to be played when the notification is delivered. You can package the audio data in an aiff, wav, or caf file. Because they are played by the system-sound facility, custom sounds must be in one of the following audio data formats:
Linear PCM
MA4 (IMA/ADPCM)
µLaw
aLaw
Note:-
Custom sounds must be under 30 seconds when played. If a custom sound is over that limit, the default system sound is played instead.
Add files to the Xcode project root.
Add file to Xcode
Make sure Add to targets is selected when adding files so that they are automatically add to the bundle resources
add the file to copy bundle resource
After that you need to set custom Sound name in app Payload:-
payload
{
aps = {
alert = "Hello World";
badge = 1;
sound = "iosTune.aiff"; // default;
};
}
Final:- when notification will receive in any stage of application then custom sound will play instead of Default sound.

Related

Change notification sound in iOS Flutter

I want to use my own sound in push notification in iOS platform of Flutter. Since I have no experience in iOS development, I am struggling with it.
In my app settings there are 3 notification sound options, so that user can choose notification sound. I have already implemented local_notifications package and although I am getting notifications in my app, I couldn't find how to use custom sound in push notification for iOS platform.
You should replace this default given sound name to your sound name.
var iOSPlatformChannelSpecifics = IOSNotificationDetails(sound: 'slow_spring_board.aiff'); //put your own sound text here
(Before this, your sounds should be added to your project using Xcode)
Here is the link how to add custom sound to your project for iOS devices using Xcode: https://medium.com/#dmennis/the-3-ps-to-custom-alert-sounds-in-ios-push-notifications-9ea2a2956c11
Note: Sound duration should be less than 30 seconds otherwise it will not work

play system sound for UILocalNotification

I found this project on GitHub: iOS Sounds and Ringtones
Is there a way to play one of those sounds for localNotification.soundName?
So I got the string for "/Library/RingtonesApex.m4r"
But it still plays the default notification sound.
UILocalNotification accepts only a sound file name, not a file path. And the docs for soundName explain that this file must be "...in the app’s main bundle...". Getting the path to a system sound file is not useful with UILocalNotification because that file is not in your app's main bundle, and because you can't tell UILocalNotification to look somewhere else.
Surely possible , you need just to move the custom sound you need to this path :
Library/Sounds ,,,by default Sounds folder is not under library ,so you need to create it , then copy any custom sound file (either after downloading to documents then copy or copying system sound ) to this directory as i said Library/Sounds . According to Apple , Sound files should be in bundle (in case get shipped with app) or in ONLY this directory Library/Sounds . You can assign only sound file name with any extension to the sound name property in local notification before iOS 10 and after iOS 10 you can assign ti to content sound name constructor . I tried it several times before and both worked for local and remote notification by either playing sound from remote server or system sound . If you need any help putting this to work in any swift versions or objective-c you're welcome .
Set for your UILocalNotification soundName property
UILocalNotification *localNoti = [UILocalNotification alloc] init];
localNoti.soundName = #"your sound with file format (exmpl.m4r)";
And make sure that your sound no longer than 30 sec. It's a limit of sound length
Hope this help
I wrote the repo you linked to in the original post.
Unfortunately, you cannot refer to the path of the sound in a localNotification. You have to have the file in the app bundle (i.e. a .MP3 file attached to your app) to use it as a custom sound.

How to change the default notification sound in iOS?

In my app I reach to Settings UI and I need a way to let the user choose specific sound for local notifications.
I searched a lot but no avail.
In Android there is RingtonePreference, is there any equivalent for iOS?
Copy the sound file in your applications bundle and it should valid iOS format sound and set the notification sound name property to set your sound file name. For help to set sound name use following code.......
notifcation.soundName = #"yourSoundName.Format" // Ex: sound.m4a
notification.soundName = #"blow.aiff"; //blow.aiff should be in main bundle
Do the following may it help:
notification.soundName = #"Example.caf";
Make sure the sound file placed in your app’s bundle, is in the correct format and is under 30 seconds in length.
best practice is to convert it to .caf format.
To convert a file to .caf, open up terminal, go to where you have your sound stored and type in:
afconvert -f caff -d LEI16#44100 -c 1 Example.wav Example.caf
Edit:
make sure you are implementing application:didreceiveLocalNotification in your app delegate.
Local notifications work on simulator, push notifications do not.
notification.soundname = #"sound file name .extension"
and make sure your app is in background so you can hear sound.

Custom sound not played when push arrives

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:
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?
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.
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.
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.

Custom iOS push notification sound

I have been facing an issue. I implemented push notification in iOS with custom sound. Its a MP3 file. It plays well when I receive a push notification in iOS 5, but in iOS4, it doesn't play any sound.
Can you help me with this?
The code is like this
{
"aps": {
"badge": 10,
"alert": "Hello",
"sound": "sound.mp3"
}
}
Nithin
According to the push notification guide:
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 application bundle.
It doesn't say anything about MP3s. I've used aif files which worked. I'd stick to what Apple specifies.
You can't play .mp3-files. However, you can convert them into .wav files here: http://media.io/ (online & free). Then put the converted file in your XCode project and you can call it by specifying "sound":"sound.wav"

Resources