3

I'm trying to find a way to use the default ringtone of an incoming call on an iPhone device.

Currently, I'm using the AVAudioplayer, i.e.

NSURL *url=[NSURL URLWithString:@"CustomSound"];
AVAudioPlayer *aplayer=[[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL];
aplayer.numberOfLoops=-1;
[aplayer play]

Is it possible to find the default Ringtone sound of the user and play it?

Thanks

Symeon Mattes
  • 1,169
  • 16
  • 40

2 Answers2

1

The recommended way is to use CallKit. Your VoIP app will then get a lot of stuff for "free". When you inject an incoming call using CallKit, iOS will automatically play the proper ringtone.

https://developer.apple.com/documentation/callkit

TALE
  • 960
  • 13
  • 22
0

there is no Public API for that, this was asked on SO in 2012 but it is still true today I think

see: How do I play the default Phone ringtone programmatically?


with undocumented enum values AudioServicesPlaySystemSound can do it but thats NOT really appstore safe.

see: Play alert sound (same as default message ringtone)


advice:

maybe use AudioServicesPlaySystemSound as: Sounds play at the current system audio volume, with no programmatic volume control available

Community
  • 1
  • 1
Daij-Djan
  • 49,552
  • 17
  • 113
  • 135