iOS中VOIP应用上的默认铃声

问题描述 投票:3回答:2

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

当前,我正在使用AVAudioplayer,即

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

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

谢谢

ios voip ringtone
2个回答
0
投票

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

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


具有未公开的枚举值,AudioServicesPlaySystemSound可以做到,但那并不是真正的应用商店安全。

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


建议:

也许使用AudioServicesPlaySystemSound作为:声音以当前系统音频音量播放,没有可用的编程音量控制


0
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.