Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
673 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...