gpt4 book ai didi

ios - 具有后台模式和来电通知的 SIP 应用程序

转载 作者:行者123 更新时间:2023-11-29 12:47:39 27 4
gpt4 key购买 nike

我正在开发 SIP 通话应用程序。我用了siphon app project实现开源 pjsip library .我能够在前台模式下为设备和模拟器成功运行应用程序。

为了在 VOIP 后台模式下运行应用程序,我正在关注 RayWenderlich Tutorial .根据 Apple Documentation ,我们必须遵循以下 4 个步骤:

  1. 在您的 Xcode 项目的“功能”选项卡的“后台模式”部分启用对 IP 语音的支持。 (您还可以通过在应用的 Info.plist 文件中包含 UIBackgroundModes 键和 voip 值来启用此支持。)
  2. 配置应用的其中一个套接字以使用 VoIP。
  3. 在进入后台之前,调用-setKeepAliveTimeout:handler: 方法来安装一个定期执行的处理程序。您的应用可以使用此处理程序来维持其服务连接。
  4. 配置您的 Audio Session 以处理与活跃使用之间的转换。

我已经实现了这第一步:

enter image description here

但我不知道如何执行接下来的三个步骤以便在后台模式下接收 SIP 调用。了解了这三个步骤背后的逻辑,但没有找到实现的任何源代码。

以前有人做过这方面的工作吗?

最佳答案

这里是我也用过的虹吸项目的 keepAlive 示例。如果你修改这个项目,你可以在 - (void)processCallState:(NSNotification *)notification 回调中做你想做的所有其他事情。

- (void)keepAlive {
/* Register this thread if not yet */
if (!pj_thread_is_registered()) {
static pj_thread_desc thread_desc;
static pj_thread_t *thread;
pj_thread_register("ipjsua", thread_desc, &thread);
}
pjsua_acc_set_registration(0, PJ_TRUE);
NSLog(@"Keep Alive");
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
/* Send keep alive manually at the beginning of background */
[self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES];

/* iOS requires that the minimum keep alive interval is 600s */
[application setKeepAliveTimeout:600 handler: ^{
[self performSelectorOnMainThread:@selector(keepAlive)
withObject:nil waitUntilDone:YES];
}];
}

不要忘记在虹吸设置中将 keepAlive 间隔设置为 600。

关于ios - 具有后台模式和来电通知的 SIP 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23246165/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com