Still receives INStartAudioCallIntent when drop support for iOS 12(INStartCallIntent)

875 Views Asked by At

I've meet a strange issue when dropping the support for iOS 12. When handle the user activity from AppDelegate continue userActivity, Although we drop INStartAudioCallIntent and INStartVideoCallIntent for it is deprecated in iOS 13, we still receive the above 2 intents from native contact card. But actually we want to handle INStartCallIntent instead. Anyone knows why this happens for my debug version is 14.6, thanks.

1

There are 1 best solutions below

1
On

Adding Intent as an app extension to handle INStartCallIntentHandling made my AppDelegate receive INStartCallIntent! It can be implemented like this:

  1. File > New -> Target -> Intent

  2. Add INStartCallIntent to Supported Intents

  3. Implement the IntentHandler (In the intent extension) like this:

    class IntentHandler: INExtension, INStartCallIntentHandling {
         override func handler(for intent: INIntent) -> Any {
             return self
         }
    
         func handle(intent: INStartCallIntent, completion: @escaping (INStartCallIntentResponse) -> Void) {
             let userActivity = NSUserActivity(activityType: NSStringFromClass(INStartCallIntent.self))
             let response = INStartCallIntentResponse(code: .continueInApp, userActivity: userActivity)
    
             completion(response)
         }
    }
    
  4. The INStartCallIntent will now be called in the AppDelegate:

    func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
    if let intent = userActivity.interaction?.intent {
        if let intent = intent as? INStartCallIntent {
            // The correct INStartCallIntent
        }
    }
    

    }