NSUserActivity:当用户从我的应用程序的最近日志中点击(或拨打电话)时,将调用哪个方法?

NSUserActivity: Which method will be called when user will tap (or will make call ) from recent log of my app?

我在 swift 中实现 CallKit,我在直接从最近的日志进行调用时遇到了 NSUserActivity 问题。

在最近的日志中点击我的应用程序条目时,我的应用程序正在启动,但没有调用 AppDelegate 的任何方法。

我已从应用程序功能中打开 Siri,并在 info.plist 中添加了 NSUserActivityType。我在 NSUserActivityType 中添加了 INStartAudioCallIntent 和 INStartVideoCallIntent。我在 AppDelegate class 中实现的方法如下:

func application(_ application: UIApplication,
                 continue userActivity: NSUserActivity,
                 restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
    print("Restoration")

    return true
}

当从最近的日志中点击我的应用程序的任何条目时,调试器控制台中会打印以下行。

AppDelegate-BAA416CD-ED84-4161-A054-B2192AFAD47A application:continueUserActivity:restorationHandler:] has an interaction attached but it is not handled

更改函数的签名,即 restorationHandler 参数类型从 ([Any]?) -> Void 更改为 ([UIUserActivityRestoring]?) -> Void

func application(_ application: UIApplication,
                 continue userActivity: NSUserActivity,
                 restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
    //if its a call

    guard let handle = userActivity.startCallHandle else {
        print("Could not determine start call handle from user activity: \(userActivity)")
        return false
    }
}

更多详情: https://github.com/Lax/Learn-iOS-Swift-by-Examples/blob/master/Speakerbox/Speakerbox/AppDelegate.swift

我更改了签名,它对我有用。