I have a list of ringtones in iOS app, also, one of the options should be the system default ringtone, that the user can select and play.
How can I obtain the ringtone that user selected and how can I play this ringtone in-app with AVAudioPlayer
, or at least get the name of the file that was selected by the user?
Asked
Active
Viewed 1,026 times
1

Tamás Sengel
- 55,884
- 29
- 169
- 223

Melany
- 466
- 7
- 20
-
Post a notification with only sound. – shallowThought Jan 19 '18 at 17:11
-
@shallowThought I meant to play in app, not to attach to notification. – Melany Jan 19 '18 at 17:27
1 Answers
1
Add import AudioToolbox
, then AudioServicesPlaySystemSound(SystemSoundID(1000))
to play a system sound.
See Audio Services for a list of sounds. Hopefully, one of those sounds will be the as UNNotificationSound.default
.
Edit
1002 seems to be the correct sound ID for the default notifcation.

Dan Bray
- 7,242
- 3
- 52
- 70
-
Does that mean if we create a notification with UNNotificationSound.default, it will always play system sound with id 1002 ? Or if we change the textTone in iPhone settings, will it play that tone instead of 1002 for UNNotificationSound.default ? – abhimuralidharan Apr 06 '22 at 04:27