Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
600 views
in Technique[技术] by (71.8m points)

ios - How can I play a recorded sound using a local notification?

I have an app that requires that the user record their own message to be played back at some future time. My intent was to do that using UILocalNotification. Unfortunately, it seems that the sound associated with the local notif has to be stored in the main bundle but the user cannot make a recording and save it in the bundle.

How do I get a user recorded sound file to be played via local notification?

Alternatively - is there a way if the app is not running to capture the local notification (without waiting for the user to respond to an alert) and then play the desired soundfile?

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can assign a (custom) sound to a UILocalNotification by setting its property as follows:

localNotification.soundName = @"MySoundFile.wav";

Unfortunately, according to the reference, it is not possible to use a sound file that is not stored in the main bundle or is declared by apple:

For this property, specify the filename (including extension) of a sound resource in the application’s main bundle or UILocalNotificationDefaultSoundName to request the default system sound.

See also UILocalNotification Class Reference #soundName


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...