iOS Callkit和背景模式(iOS Callkit and Background Mode)

编程入门 行业动态 更新时间:2024-10-19 17:36:02
iOS Callkit和背景模式(iOS Callkit and Background Mode)

我正在编写一个VoIP应用程序,它在应用程序处于后台时使用CallKit。 大部分情况都可以正常工作,并且CallKit在来电时在后台推送应用程序方面做得很好。

据我了解,一旦在背景和所有未完成的任务已完成,应用程序进入“休眠”,并停止与外界沟通。 现在,应用恢复活力的唯一方式是当iOS操作系统告诉它 - 当操作系统检测到传入的VoIP呼叫时,它会将此传递到应用程序,并且应用程序将恢复活动并且接电话。

我的问题是:偶尔我的应用程序崩溃或用户注销,在这种情况下,它不能接听电话。 如果这种情况发生在后台,我怎么知道? 我想通过某种方式告诉来电者他不能拨打电话,因为接收方无法接通? iOS操作系统仍会尝试推送。

I am writing a VoIP app which uses CallKit for when the app is in the background. Largely everything works fine, and CallKit does a nice job of pushing the app when it is in the background during an incoming call.

As far as I understand, once in the background and all outstanding tasks have been finished, the app goes into 'hibernation' and stops communicating with the outside world. The only way now for the app to come back alive is when the iOS operating system tells it to -- when an incoming VoIP call is detected by the operating system, it will pass this on to the app and the app will come back alive and take the call.

My question is: occasionally my app crashes or the user gets logged out, in which case it cannot take calls. If it's in the background when this happens, how can I find out? I'd like some way of telling the caller that he can't call because the receiver is unreachable? iOS operating system will still try to push.

最满意答案

如果您正在使用PushKit(实际上是实施静默推送通知的推荐方式),则在推送通知到达系统时,将调用委托函数。

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void)

上述功能将在前面

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool

当推送通知到达时应用程序终止或崩溃。

VoIP推送通知的概念是以最节能的方式唤醒应用程序。 所以它会帮助你唤醒用户通知有关呼叫。

If you are using PushKit ( which is actually the recommended way to implement silent push notification ) below delegate function will be called when a push notification arrives to the system.

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void)

The above function will be preceded by

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool

when the application is terminated or crashed when push notification arrives.

The concept of VoIP push notification is to wake up the app in most energy efficient way. So it will help you to wake up the subscriber to notify about call.

更多推荐

本文发布于:2023-08-04 07:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1412517.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:背景   模式   Callkit   iOS   Background

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!