iOS中的呼叫目录扩展如何更新 [英] How does the Call Directory Extension in iOS get updated

查看:160
本文介绍了iOS中的呼叫目录扩展如何更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在开发的应用程序,我想使用CallKit的呼叫目录扩展来存储数千个电话号码。



我很困惑大约是,如何以及何时调用该扩展名?似乎并非每次通话都发生这种情况。



我问的原因是,我不想在应用程序中保留成千上万个电话号码。



我不希望用户看到这些电话号码(当然,除非他们接到其中一个打来的电话)。因此,我要做的是使用扩展程序一次保存电话号码,并从Web服务中加载电话号码,但只能定期进行。



谢谢!

解决方案

只要用户可以通过来电显示设置将其打开。您还可以使用 CXCallDirectoryManager reloadExtension 方法手动重新加载它。



您需要使用应用程序组在主应用程序和扩展之间共享数据。



您的主应用程序负责定期获取数据(使用任何方法)您喜欢;由用户手动触发或例如后台获取)并更新共享数据库。然后,它调用 CXCallDirectoryManager.sharedInstance.reloadExtension(withIdentifier:completionHandler:)重新加载扩展。 标识符是您的CallKit扩展的字符串捆绑ID。



该扩展仅需要从共享数据库中检索所有数据,并使用 CXCallDirectoryExtensionContext 进行注册


I have an app that I'm developing and I want to store a few thousand phone numbers using the Call Directory Extension of CallKit.

What I'm confused about is, how and when does the extension get called? It doesn't seem like it happens with every phone call. Does it happen whenever the app is started?

The reason I'm asking, I don't want to keep the thousands of phone numbers in my app. I don't want the user to see these phone numbers (unless of course, they get a call from one of them). So, what I want to do is save the phone numbers using the Extension one time, with numbers loaded from a web service, but only periodically.

Thank you!

解决方案

The extension will be loaded whenever the user turns it on from the caller ID settings. You can also manually reload it using the reloadExtension method of CXCallDirectoryManager.

You need to share data between your main app and the extension using an App Group.

Your main app is responsible for fetching the data periodically (using whatever method you like; manual trigger by the user or background fetch for example) and updating the shared database. It then calls CXCallDirectoryManager.sharedInstance.reloadExtension(withIdentifier:completionHandler:) to reload the extension. identifier is the string bundle id of your CallKit extension.

The extension simply needs to retrieve all of the data from the shared database and register it with the CXCallDirectoryExtensionContext

这篇关于iOS中的呼叫目录扩展如何更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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