Reputation: 1470
Im integrating local notification into my app.
It is working fine.
But client want to use a different sound for local notification.
I drag and drop the file into the supporting files of xcode
Can anyone please help me how to do this.
code
AlocalNotifas.soundName = @"cling.wav";
localNotifas.soundName = [[NSBundle mainBundle] pathForResource:@"cling" ofType:@".wav"];
// [localNotifas setSoundName:[[NSBundle mainBundle] pathForResource:@"cling" ofType:@"wav"]];
// [localNotifas setSoundName:UILocalNotificationDefaultSoundName];
Can you experts please show me where im going wrong.
Upvotes: 1
Views: 5233
Reputation: 149
Use your local notification object and set its soundName property to sound file
[localNotif setSoundName:@"abc.mp3"];
Upvotes: 1
Reputation: 3138
Be sure to copy the sound file in the root of the project.
you can also use the name of the sound directly, by example...
localNotif.soundName = @"marimba.mp3";
Upvotes: -4
Reputation: 11970
Remember that your notification sounds may not be longer than 30 seconds - if the file supplied is longer, nothing will sound.
Also, check the sound in some external player first, and best 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 yourfile.wav yourfile.caf
Then just set it like:
yourNotification.soundName = @"yoursound_name.caf";
Upvotes: 16