How do I play the default Phone ringtone programmatically?
Asked Answered
E

3

9

I have been working on a conference related app. I want to show ringing notification for the incoming call. I have tried with AVAudioPlayer, and it worked fine for custom sounds. My question is, is it possible to get default ringtone from iPhone (user selected tone in settings) and play for my app?

thanks for your valuable suggestions...

Enlargement answered 25/9, 2012 at 7:4 Comment(1)
You can play your custom sound as Answer https://mcmap.net/q/323317/-play-audio-ios-objective-cGrocery
T
4

No, no SDK API for get iPhone ringtones.

But you can download those from another links and add to your project

Tsunami answered 25/9, 2012 at 7:23 Comment(4)
So every time I need to download if the user changes sound in settings?Enlargement
you can add all standard ringtones and choose a true ringtoneTsunami
Is this still true in iOS 8 ?Praseodymium
@Praseodymium Try to use g8production.com/post/83956349090/…Tsunami
L
5

Someone has asked a similar question here but overall it does not appear possible, at least if you want to distribute your application through the App Store. On a jailbroken phone, you may find this answer useful.

Lardy answered 25/9, 2012 at 7:28 Comment(0)
T
4

No, no SDK API for get iPhone ringtones.

But you can download those from another links and add to your project

Tsunami answered 25/9, 2012 at 7:23 Comment(4)
So every time I need to download if the user changes sound in settings?Enlargement
you can add all standard ringtones and choose a true ringtoneTsunami
Is this still true in iOS 8 ?Praseodymium
@Praseodymium Try to use g8production.com/post/83956349090/…Tsunami
B
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

There are a lot of things that CallKit handles for you. Things like:

  • showing a proper incoming call screen when the phone is locked
  • what happens if the user is already on another call
  • "Do not disturb" is on (either driving or sleeping)
  • the phone is set to silent
  • playing the proper ringtone
Buell answered 19/9, 2019 at 15:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.