天天看點

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>