在后台运行VOIP(PJSIP)服务 [英] Running a VOIP (PJSIP) service in the background

查看:271
本文介绍了在后台运行VOIP(PJSIP)服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序刚刚被Apple拒绝,因为它无法正确实现后台运行,并且是使用iOS的VOIP应用程序.

My app has just been rejected by Apple as it does not properly implement background running and it is a VOIP app using iOS.

使它保持运行的我的奇怪代码是

My odd code that kept it running was

[self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES];
[application setKeepAliveTimeout:KEEP_ALIVE_INTERVAL handler: ^{
  [self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES];
}];

我知道错了

然后我跟随

http://blog.dkaminsky.info/2013/01/27/keep-your-ios-app-running-in-background-forever/,这是使其始终运行的VOIP hack.我再次认为这是错误的.

http://blog.dkaminsky.info/2013/01/27/keep-your-ios-app-running-in-background-forever/ which is the VOIP hack to get it running all the time. Again I think this is wrong.

我基本上只需要调用一种方法来使PJSIP保持活动状态.

I basically just need to call one method to keep PJSIP alive.

我应该如何正确执行此操作?

How should I do this properly?

更新

我看过Apple指南,看来这是正确的

I have looked at the Apple guide, it appears this is correct

[application setKeepAliveTimeout:KEEP_ALIVE_INTERVAL handler: ^{
        [self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES];
        NSLog(@"Fire");
    }];

但是我不确定如何配置PJSIP TCP端口在后台运行.

However I am not sure how to configure PJSIP TCP port to run in the background.

APPLE:配置应用程序的其中一个套接字以用于VoIP.

APPLE : Configure one of the app’s sockets for VoIP usage.

后台运行良好,只是苹果公司拒绝了

2.16

我们发现您的应用使用后台模式,但不包含要求该模式持续运行的功能.此行为不符合《 App Store审查指南》.

We found that your app uses a background mode but does not include functionality that requires that mode to run persistently. This behavior is not in compliance with the App Store Review Guidelines.

我们注意到您的应用在Info.plist的UIBackgroundModes项中声明了对VoIP的支持,但不支持来自已连接的VoIP服务的来电.

We noticed your app declares support for VoIP in the UIBackgroundModes key in your Info.plist but does not support incoming calls from the connected VoIP service.

如果您的应用程序不支持来自其连接的VoIP服务的传入呼叫,则voip后台模式不适用.如《 iOS编程指南》中所述,此密钥用于需要监视套接字以接收传入呼叫的​​应用程序:

If your application does not support incoming calls from it's connected VoIP service, the voip background mode is not appropriate. As indicated in the iOS Programming Guide, this key is for applications that need to monitor sockets for incoming calls:

系统不是使VoIP应用程序始终保持唤醒状态,而是允许它们挂起并提供用于监视其套接字的功能.当检测到传入流量时,系统将唤醒VoIP应用程序并返回对其套接字的控制权来."

"Rather than keep VoIP apps awake all the time, the system allows them to be suspended and provides facilities for monitoring their sockets for them. When incoming traffic is detected, the system wakes up the VoIP app and returns control of its sockets to it."

请注意使用Info.plist文件的UIBackgroundModes密钥中的音频"值.当您的应用程序在后台运行时,使用音频后台模式将使当前的拨出VoIP通话保持打开状态.

Please look into using the "audio" value in the UIBackgroundModes key of your Info.plist file. Using the audio background mode will keep current out-going VoIP calls open while your app is in the background.

添加VoIP功能或从UIBackgroundModes键中删除"VoIP"设置是适当的.对于离散的代码级问题,您可能希望向Apple开发人员技术支持咨询.请确保:

It would be appropriate to add VoIP features or remove the "VoIP" setting from the UIBackgroundModes key.For discrete code-level questions, you may wish to consult with Apple Developer Technical Support. Please be sure to:

更新2

PJSIP告诉我套接字已标记为VOIP,所以我不知道为什么会拒绝它

PJSIP has told me that the sockets are marked for VOIP and so I have no idea why this is being rejected

推荐答案

,您应选中声明应用程序支持的后台任务"部分.在链接 iOS应用编程指南

you should check section in "Declaring Your App’s Supported Background Task". in link iOS App Programming Guide

实施VoIP应用

互联网协议语音(VoIP)应用程序使用户可以使用Internet连接而不是设备的蜂窝电话来拨打电话.这样的应用程序需要维持与其相关服务的持久网络连接,以便它可以接收传入的呼叫和其他相关数据.该系统不是让VoIP应用程序始终保持唤醒状态,而是允许它们挂起并提供用于监视其套接字的功能.当检测到传入流量时,系统将唤醒VoIP应用程序,并将对它的套接字的控制权返回给它.

A Voice over Internet Protocol (VoIP) app allows the user to make phone calls using an Internet connection instead of the device’s cellular service. Such an app needs to maintain a persistent network connection to its associated service so that it can receive incoming calls and other relevant data. Rather than keep VoIP apps awake all the time, the system allows them to be suspended and provides facilities for monitoring their sockets for them. When incoming traffic is detected, the system wakes up the VoIP app and returns control of its sockets to it.

要配置VoIP应用,您必须执行以下操作:

To configure a VoIP app, you must do the following:

Enable support for Voice over IP from the Background modes section of the Capabilities tab in your Xcode project. (You can also enable this support by including the UIBackgroundModes key with the voip value in your app’s Info.plist file.)

Configure one of the app’s sockets for VoIP usage.

Before moving to the background, call the setKeepAliveTimeout:handler: method to install a handler to be executed periodically. Your app can use this handler to maintain its service connection.

Configure your audio session to handle transitions to and from active use.

在UIBackgroundModes密钥中包含voip值可让系统知道它应允许应用程序根据需要在后台运行以管理其网络套接字.系统启动后,具有此密钥的应用程序也会在后台立即重新启动,以确保VoIP服务始终可用.

Including the voip value in the UIBackgroundModes key lets the system know that it should allow the app to run in the background as needed to manage its network sockets. An app with this key is also relaunched in the background immediately after system boot to ensure that the VoIP services are always available.

开发VoIP应用程序的提示."

这篇关于在后台运行VOIP(PJSIP)服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆