問題描述
我是 ios 新手.我想知道是否有任何方法可以檢測來電、去電等呼叫事件,即使我的應用程序不在前臺也是如此.如果是,那么我可以閱讀有關該呼叫的詳細信息,例如持續時間,是否未接,已撥或已接.提前致謝.
I am new to ios. I was wondering if there is any way to detect the call events like incoming call, outgoing call even if my app is not in foreground. And if yes it is possible then can i read the details about that call like duration, whether it is missed, dialed or recieved. Thanks in advance.
推薦答案
是的,您可以檢測到呼叫.但前提是您的應用程序在前臺運行.為此,您可以使用核心電話框架.
Yes you can detect a Call. but only if your app is running in the foreground. For this you can use the Core Telephony Framework.
如果您的應用屬于任何后臺運行類別(VOIP、音頻、位置跟蹤或附件),您也許可以使用CTCallCenter代碼> 在后臺.但請注意,如果您錯過將后臺運行模式用于不適合的用途,Apple 會拒絕您的應用.
If your app will fall in any of the background running categories (VOIP, AUDIO, Location tracking or accessory ) you might be able to use the
CTCallCenter
in the background. But be aware that Apple will reject you app if you miss use the background running mode for something it was not meant for.
CTCallCenter
將允許您檢測任何已啟動或正在進行的呼叫.
The CTCallCenter
will allow you to detect any calls that are started or already in progress.
但是,您將無法檢測到有關呼叫的任何詳細信息,CTCall
識別調用只會告訴你這個狀態.CTCall
只會為您提供呼叫的唯一標識符,而不是被呼叫的號碼.
However you will not be able to detect any detail about the call, the CTCall
identifying the call will only tell you this state. The callID
of CTCall
will just give you an unique identifier for the call but not the number being called.
這篇關于檢測ios中的通話事件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!