Wajih
Wajih

Reputation: 4383

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?

Upvotes: 0

Views: 1071

Answers (4)

Muhammad Salman
Muhammad Salman

Reputation: 553

notification.soundname = @"sound file name .extension"

and make sure your app is in background so you can hear sound.

Upvotes: 0

Ronak Chaniyara
Ronak Chaniyara

Reputation: 5435

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.

Upvotes: 0

Naresh Reddy M
Naresh Reddy M

Reputation: 1096

notification.soundName = @"blow.aiff"; //blow.aiff should be in main bundle

Upvotes: 1

UIResponder
UIResponder

Reputation: 983

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

Upvotes: 2

Related Questions