user1949873
user1949873

Reputation: 460

is there a way to let the user choose the sound for local notification?

I have an app that has 64 local notifications with repeat intervals. So I can't add more notifications, or otherwise, I'd need the user to open the app again for a reschedule.

I was wondering if I'm able to let the user choose the file with in this code:

notif.soundName = @"xxx.wav";

so they can choose xyz.wav instead?

Upvotes: 1

Views: 359

Answers (1)

BalestraPatrick
BalestraPatrick

Reputation: 10144

Yes, you can let the user choose the sound between some that are already in your project or you could also let him take a song from the music library.

Update: If the files are already in your Xcode project, you can create a NSString or a int value to store the user choose. You create a button that let the user choose a sound. You connect this button to change the string or int value. Then you create and if statement that check this string or int and change properly the UILocalnotification sound.

int soundNumber;

- (IBAction)chooseSoundName {
   soundNumber = 1;
}

- (void)loadSoundName {
   if(SoundNumber == 1) {
       localNotification.soundName = @"first.wav";
   }
}

Then you call the loadSoundName method (or you could integrate it into another method).

Hope it helps

Upvotes: 1

Related Questions