Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
676 views
in Technique[技术] by (71.8m points)

ios - How to get the voip call log information in application - Call Kit

I have implemented call kit in my voip app in which i generate the call logs for incoming or outgoing calls (visible on phone recent tab). When i click on call logs it will open my app. I've overridden the UIApplication delegate method to get the handler.

- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
 restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler  

But i unable to get call log related information in NSUserActivity. How i can get the call log information in my app?

Any help much appreciate. Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Complete solution in Swift 4

You need to configure your app to get continue userActivity called.

  • Add supportedHandleTypes property in CXProviderConfiguration

        let configuration = CXProviderConfiguration.init(localizedName:"Product name")
        configuration.supportedHandleTypes = Set([CXHandle.HandleType.generic])
    
  • Add NSUserActivityTypes of type INStartAudioCallIntent in Info.plist of your project enter image description here

  • Target Project -> Build Phase -> Libraries add Intents.framework

  • Import Intents framework in your AppDelegate
  • Below is the code to extract phone number from userActivity

    func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
        let intraction = userActivity.interaction
        let startAudioCallIntent = intraction?.intent as? INStartAudioCallIntent
        let contact = startAudioCallIntent?.contacts?[0]
        let contactHandle = contact?.personHandle
        if let phoneNumber = contactHandle?.value {
           print(phoneNumber)
        }
        return true
    }
    

    Hope this helps You.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...