天天看点

iOS反骚扰电话-CallKit

电话号码是用call directory extension事先存在系统里的,当来电时,系统会查询存储的数据, 根据号码绑定的label,决定直接屏蔽还是显示来电。

iOS反骚扰电话-CallKit

ios-callkit.png

<a href="http://stackoverflow.com/questions/38098036/how-to-get-the-incoming-call-number-by-using-callkit" target="_blank">http://stackoverflow.com/questions/38098036/how-to-get-the-incoming-call-number-by-using-callkit</a>

<a href="https://www.zhihu.com/question/47542405" target="_blank">https://www.zhihu.com/question/47542405</a>

1 . 新建一个工程,new 一个 target,选<code>call directory extension</code> ,会自动生成模版代码。

2 . 手工给extension 生成 一个 calldirectoryextension.entitlements 文件。

3 . 运行。在设备的设置 —&gt; 电话 —&gt; call blocking &amp; identification,开启我们的 app。

4 . 打电话

iOS反骚扰电话-CallKit

img_4610.png

该方法在 containing app 调用 reload 或者在 设置 —&gt; 电话 —&gt; call blocking &amp; identification里开启权限的时候,会自动被调用。但是打断点的时候,无法进来。

数据量大时,需要分批处理,注意内存问题。consider only loading a subset of numbers at a given time and using autorelease pool(s) to release objects allocated during each batch of numbers which are loaded.

号码升序排列。 numbers must be provided in numerically ascending order

号码需要加区号。 edit retrievephonenumberstoidentifyandlabels() to include the number and label you want. add +countrycode at the start (not confirmed yet if this is essential)

<a href="https://forums.developer.apple.com/thread/48837" target="_blank">https://forums.developer.apple.com/thread/48837</a>