如何在设备上的前台app中显示双倍高度绿色状态栏(In-Call)? [英] How to show double height green statusbar (In-Call) in foreground app on device?
问题描述
这里有很多问题要求在后台显示红色录音条。很明显我应该使用 AVAudioSession
类别 AVAudioSessionCategoryPlayAndRecord
。我的问题是,在我的应用程序中进行有效的VOIP呼叫时,如何在前台应用中显示绿色的通话栏(或至少红色条)?所以我可以返回调用UI点击状态栏区域,就像
这是WhatsApp(Reveal无法获得真正的快照,但它传达了基本想法):
在这两个应用程序中,它是一个UIView,从屏幕顶部开始,有几种格式输出文本/句柄触摸的方法在它上面推出了 CallKit.framework ,但似乎它没有那种功能,所以唯一的方法就是这样做 - 自己做。
There's a lot of questions here asking for displaying a red recording bar while in background. It's totally clear I should use AVAudioSession
category AVAudioSessionCategoryPlayAndRecord
for that. My question is how can I display a green In-Call bar (or at least red bar) in a foreground app when having an active VOIP call in my app? So I could return to call UI tapping a statusbar area, just like Whatsapp or Skype does.
What I've already tried:
voip
andaudio
modes inUIBackgroundModes
key in Info.plist +setCategory:AVAudioSessionCategoryPlayAndRecord
+setActive
as suggested in this SO answer (gives me a red statusbar when going background, but nothing while in foreground)- Previous +
AVAudioSession
+setMode:AVAudioSessionModeVoiceChat
- didn't work - Set
kCFStreamNetworkServiceTypeVoIP
flag to socket in pjsip sources and recompiled it - didn't help. Also, deprecated since iOS 8. - Created a separate socket, set the voip flag for inputStream/outputStream:
[self.inputStream setProperty:NSStreamNetworkServiceTypeVoIP forKey:NSStreamNetworkServiceType]
(took the sample code from here)
Using pjsip for calls. What else can I try to increase a statusbar height, moving all the UI down? Are there any standard ways to do that, or I should hack it my own by resizing a root UIWindow and setting another green UIWindow under the statusbar?
Edit: Since no answer is found for a standard way to do that, accepted @roman-ermolov answer. For those who will search for an answer I may suggest several options to do it yourself:
- Wrap your root viewcontroller inside container, like in Apple's iAdSuite with Storyboards example. Take a look at my sample project for example. Probably the best way to make that bar.
- Hack UINavigationBar height (see this approach) - doesn't work for landscape yet, but may probably be solved
- Control your main UIWindow's frame yourself, place another UIWindow under the statusbar with the desired content.
I have made an investigation of both apps (WhatsApp & Skype) and learned that they used their own UIView for achieving this functionality.
This is Skype:
This is WhatsApp (Reveal can't get real snapshot, but it transmits basic idea):
In both apps it is a UIView which starts on top of the screen and several methods for format output text / handle touch on it.
In iOS 10 Apple introduced CallKit.framework, but it seems that it has not that kind of functionality too, so the only way to do it - do it yourself.
这篇关于如何在设备上的前台app中显示双倍高度绿色状态栏(In-Call)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!