简体   繁体   English

为什么后台任务在10分钟后结束

[英]Why background task is ending after 10 minutes

I am badly in need of a background task to run always, when application is in background. 当应用程序在后台运行时,我非常需要后台任务始终运行。

It is needed for a voip application. voip应用程序需要它。 All steps are done for voip app. 所有步骤均已针对voip应用程序完成。

I am using following script to run background task 我正在使用以下脚本来运行后台任务

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    UIApplication *app = [UIApplication sharedApplication];
    UIBackgroundTaskIdentifier bgTask;
    self.bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
        [app endBackgroundTask:self.bgTask];
    }];
}

After using it, when application goes to background, within 10 minutes if a sip call comes UILocalnotification appear. 使用它后,当应用程序进入后台时,如果出现UILocalnotification调用,将在10分钟内显示UILocalnotification but after 10 minutes if a sip call comes UILocalnotification did not appear. 但是10分钟后,如果出现了Sip呼叫,则不会出现UILocalnotification。

Please anybody help me. 请任何人帮助我。

您是否已将voip作为背景模式添加到应用程序Info.plist文件中的UIBackgroundModes项中?

There may be a possibility that your app is crashing because of many requests in background.I hope that you already followed these steps: 您的应用可能由于后台的许多请求而崩溃。我希望您已经按照以下步骤操作:

There are several requirements for implementing a VoIP app: 实施VoIP应用程序有一些要求:

  • Add the UIBackgroundModes key to your app's Info.plist file. 将UIBackgroundModes键添加到应用程序的Info.plist文件中。 Set the value of this key to an array that includes the voip string. 将此键的值设置为包含voip字符串的数组。

    • Configure one of the app's sockets for VoIP usage. 配置应用程序的一个套接字以使用VoIP。

    • Before moving to the background, call the 移至背景之前,请致电

    • setKeepAliveTimeout:handler: method to install a handler to be setKeepAliveTimeout:handler:方法将要安装的处理程序
    • 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. 配置您的音频会话,以处理到主动使用之间的过渡。

    To ensure a better user experience on iPhone, use the Core Telephony framework to adjust your behavior in relation to cell-based phone calls; 为了确保在iPhone上获得更好的用户体验,请使用Core Telephony框架来调整与基于手机的电话有关的行为; see Core Telephony Framework Reference. 请参阅《 Core Telephony Framework参考》。

  • To ensure good performance for your VoIP app, use the System Configuration framework to detect network changes and allow your app to sleep as much as possible. 为确保VoIP应用程序具有良好的性能,请使用“系统配置”框架来检测网络变化并让您的应用程序尽可能多地进入睡眠状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM