How do I play the default Phone ringtone programmatically?

折月煮酒 提交于 2019-12-01 03:51:19
CReaTuS

No, no SDK API for get iPhone ringtones.

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

dreamlax

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.

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!