iOS - 在 VoIP 应用程序上发送来电通知的最佳实践 [英] iOS - best practice to send incoming call notifications on VoIP app

查看:34
本文介绍了iOS - 在 VoIP 应用程序上发送来电通知的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于来电通知,我能想到的第一个解决方案是 Apple 的 Push Notification 服务.但是,不能保证……丢失的可能性相对较高……而在 VoIP 应用程序中,来电通知非常重要,我不能经常错过……

The first solution I can think of for the incoming call notification is Apple's Push Notification service. However, it is not guaranteed.. there's a relatively high chance it may get lost.. and in a VoIP app, the incoming call notification is so important that I can't afford to miss it too often...

因此,我遵循了提示并启用了后台模式使应用程序保持活动状态并收听任何来电邀请.没错,当应用收到来电邀请时,我应该只显示本地通知.当应用程序处于后台/非活动状态时,这非常有效.然而,当用户手动杀死应用程序时,不会执行任何代码,因此在这种情况下应用程序不会收到任何来电邀请......并且由于这种特殊情况,我仍然必须依赖远程推送通知.

Thus, I followed the tips and enabled the Background Mode to keep the app alive and listening to any incoming call invite. By right, I should just show local notification when the app gets the incoming call invite. This works pretty well when the app is in background/inactive. HOWEVER, when user kills the app manually, no code will get executed, so the app won't get any incoming call invite in such a condition... And because of this particular scenario, I still have to rely on remote push notification.

我想要实现的是..首先等待远程通知,如果它到达,则不再显示本地通知.如果丢失,则显示本地通知,以便用户始终收到通知.

What I'm trying to achieve is.. waiting for remote notification first, if it arrives, then do not show local notification anymore. If it's lost, then show local notification so that user will always get notified.

问题是...我无法判断远程通知是否已到达.

The problem is... I have no way to tell if a remote notification has arrived.

我想知道处理 VoIP 应用的来电通知的最佳做法是什么?

I want to know what is the best practice to handle incoming call notifications for a VoIP app?

推荐答案

来自 appleDoc Apple 开发人员文档.(更新链接)

From appleDoc Apple Developer Docs. (Updated link)

在 iOS 8 及更高版本中,IP 语音 (VoIP) 应用程序注册 UIRemoteNotificationTypeVoIP 推送通知,而不是使用此方法.使用推送通知消除了对超时处理程序签入 VoIP 服务的需要.相反,当用户有来电时,VoIP 服务会向用户的设备发送 VoIP 推送通知.收到此通知后,设备会根据需要启动或唤醒应用,以便处理来电.

In iOS 8 and later, voice-over-IP (VoIP) apps register for UIRemoteNotificationTypeVoIP push notifications instead of using this method. Using push notifications eliminates the need for a timeout handler to check in with the VoIP service. Instead, when a calls arrives for the user, the VoIP service sends a VoIP push notification to the user’s device. Upon receiving this notification, the device launches or wakes the app as needed so that it can handle the incoming call.

这篇关于iOS - 在 VoIP 应用程序上发送来电通知的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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