应用程序未处于活动状态时的CTCall eventHandler

时间:2015-08-31 22:38:19

标签: ios swift core-telephony

我已经实现了CTCallCenter并在app位于前台时获取eventhandler调用。有什么方法可以在我的应用程序不在内存或后台时调用它。

另见How to get a call event using CTCallCenter:setCallEventHandler: that occurred while the app was suspended?

func block (call:CTCall!) {
    NSUserDefaults.standardUserDefaults().setValue(call.callState, forKey:"state")
    NSUserDefaults.standardUserDefaults().synchronize()

    println(call.callState)
}



 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
     println(NSUserDefaults.standardUserDefaults().valueForKey("state"))
    callcenter.callEventHandler = block
    return true
}

用例:我希望在接到电话时打开LED。只是为了显示状态。不会上传到应用程序商店,所以不必担心应用程序被拒绝。

0 个答案:

没有答案