您是否嘗試過創建呼叫中心和AppDelegate類分配處理程序塊?以下必須工作。
import UIKit
import CoreLocation
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let callCenter: CTCallCenter = CTCallCenter()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window?.rootViewController = ViewController()
window?.makeKeyAndVisible()
callCenter.callEventHandler = {
(call: CTCall!) in
switch call.callState {
case CTCallStateConnected:
print("CTCallStateConnected")
case CTCallStateDisconnected:
print("CTCallStateDisconnected")
case CTCallStateIncoming:
print("CTCallStateIncoming")
default:
print("default")
}
}
return true
}
}
不要忘記在背景模式這種切換。並在背景中執行某些操作,就像接收位置一樣。
您找到的任何解決方案?如果是這樣,我可以請求您發佈它嗎? –
不,我還沒有找到任何解決方案。 – milanpanchal
那麼你是怎麼進行的? –