目标背景任务c

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

当应用程序处于前台时,SIP呼叫正常工作。

我的问题是,当我的应用程序在后台SIP电话后10分钟后不工作。

我已经在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

我对此很有耐心。

请任何机构帮助我。 请。

根据我的理解, beginBackgroundTaskWithExpirationHandler方法用于在后台执行有限长度任务。 看到这里 。 而我所发现的这10分钟的时间是无法延续的。

由于你的应用程序分类为背景模式所需的应用程序,我不认为你会需要beginBackgroundTaskWithExpirationHandler。

阅读上面链接中的“实现VoIP应用”部分。它主张使用setKeepAliveTimeout:handler:方法。