目标 c 中的后台任务 [英] Background task in objective c

查看:31
本文介绍了目标 c 中的后台任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在objective-c中有一个VOIP应用

I have a VOIP application in objective-c

当应用程序在前台时,SIP 呼叫工作正常.

SIP call is working fine when application is in foreground.

我的问题是当我的应用程序处于后台时,进入后台 10 分钟后 SIP 呼叫无法正常工作.

My problem is when my app is in background SIP call is not working after 10 minutes after going to background.

我在 applicationDidEnterBackground

bgTask = [application beginBackgroundTaskWithExpirationHandler:^{

    // Clean up any unfinished task business by marking where you

    // stopped or ending the task outright.

    [application endBackgroundTask:bgTask];

    bgTask = UIBackgroundTaskInvalid;

}];



// Start the long-running task and return immediately.

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{



    // Do the work associated with the task, preferably in chunks.



    [application endBackgroundTask:bgTask];

    bgTask = UIBackgroundTaskInvalid;

});

在 plist 文件中 UIBackgroundModes 设置为 voip

In plist file UIBackgroundModes is set to voip

我对此很有耐心.

请任何机构帮助我.请.

Please any body help me. Please.

推荐答案

据我所知,beginBackgroundTaskWithExpirationHandler 方法用于在后台执行 Finite-Length 任务.请参阅此处.而且我发现的 10 分钟的时间无法延长.

By my understanding the beginBackgroundTaskWithExpirationHandler method is used for executing a Finite-Length Task in the Background. See Here. And there is no way extend that period of 10 mins which I have discovered.

由于您的应用被归类为后台模式所需的应用,我认为您不需要beginBackgroundTaskWithExpirationHandler.

Since your app classifies as a background mode required app, I dont think you will be needing beginBackgroundTaskWithExpirationHandler.

阅读实施 VoIP 应用程序";上面链接中的部分,提倡使用setKeepAliveTimeout:handler:方法.

Read "Implementing a VoIP App" section in the above link.It advocates the use of setKeepAliveTimeout:handler: method.

这篇关于目标 c 中的后台任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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