iOS中VOIP应用的默认铃声

时间:2016-02-10 16:21:34

标签: ios voip ringtone

我正试图找到一种方法来在iPhone设备上使用来电的默认铃声。

目前,我正在使用AVAudioplayer,即

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

是否可以找到用户的默认铃声并播放它?

谢谢

2 个答案:

答案 0 :(得分:0)

没有公共API,2012年在SO上提出了这个问题,但我认为今天仍然如此

请参阅:How do I play the default Phone ringtone programmatically?

使用未记录的枚举值AudioServicesPlaySystemSound可以做到这一点,但那不是真的appstore安全。

请参阅:Play alert sound (same as default message ringtone)

建议:

可能使用AudioServicesPlaySystemSound:声音播放当前系统音量,没有可用的编程音量控制

答案 1 :(得分:0)

推荐的方法是使用CallKit。然后,您的VoIP应用将获得很多“免费”的东西。当您使用CallKit插入来电时,iOS将自动播放适当的铃声。

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