• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

iOS PjSip - 后台工作

[复制链接]
菜鸟教程小白 发表于 2022-12-12 21:51:57 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

最近我必须使用 voip 实现后台工作应用程序。为此,我使用 PJSip。 现在我已经完成了在应用程序运行时完美地注册和处理调用。

当应用程序进入后台时,前 10 分钟工作正常 -> 新来电被捕获并作为本地通知发送 - 所以这很好。 10 分钟后,sip 停止工作并且来电也没有到达。

你能帮我解决这个问题吗?

我已检查“免费工作 - VoiP” 我已经通过 siphon2 示例应用程序在 pjsip 中保持事件状态。

我也有:

- (void)applicationDidEnterBackgroundUIApplication *)application
{
    [[PjSipService service] setIsInBackground:YES];
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    int KEEP_ALIVE_INTERVAL = 600;

    [self performSelectorOnMainThreadselector(keepAlive) withObject:nil waitUntilDone:YES];
    NSLog(@"startingKeepAliveTimeout1");

    [application setKeepAliveTimeout:KEEP_ALIVE_INTERVAL handler: ^{
        NSLog(@"startingKeepAliveTimeout2");

        [self performSelectorOnMainThreadselector(keepAlive) withObject:nil waitUntilDone:YES];
    }];


    __block UIBackgroundTaskIdentifier bgTask;

    bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
        [application endBackgroundTask:bgTask];
        bgTask = UIBackgroundTaskInvalid;
    }];


    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        //[self deregis];
        [application endBackgroundTask: bgTask]; //End the task so the system knows that you are done with what you need to perform
        bgTask = UIBackgroundTaskInvalid; //Invalidate the background_task

         NSLog(@"\n\nRunning in the background!\n\n");
    });
}

“keepAlive”函数为空。 我已经读过这个函数keepAlive就足够了——但是没有后台任务它甚至不能工作10分钟。

应用程序必须在 iOS7 和 iOS6 中运行



Best Answer-推荐答案


在后台运行的应用程序,是使用 IOS 中的 setKeepAliveTimeout 方法执行的。但从以后的版本开始,setKeepAliveTimeout 方法已被弃用。

您想使用远程通知来接听来电。特别是对于VOIP来电,苹果引入了Callkit框架。请按照该框架在您的 VOIP 应用程序处于后台状态时接听来电。

https://www.raywenderlich.com/150015/callkit-tutorial-ios

关于iOS PjSip - 后台工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23364782/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap