使用iOS13.7、Swift5.2.4、XCode11.7、
我尝试在我的 iOS 应用程序中删除现有的 INInteraction。
INShortcut 创建如下:
@available(iOS 12.0, *)
func createSiriButton(documentID: String, invitationCode: String) -> INUIAddVoiceShortcutButton {
let siriShortcutButton = INUIAddVoiceShortcutButton(style: .whiteOutline)
let activity = NSUserActivity(activityType: "MyIdentifierStringCodeABCDEF")
activity.title = "Test"
activity.suggestedInvocationPhrase = "Test"
activity.isEligibleForSearch = true
activity.isEligibleForPrediction = true
activity.persistentIdentifier = NSUserActivityPersistentIdentifier("MyIdentifierStringCodeABCDEF")
activity.becomeCurrent()
siriShortcutButton.shortcut = INShortcut(userActivity: activity)
return siriShortcutButton
}
之后,ActivityPersistentIdentifier
在手头,我尝试删除INInteraction。
我尝试了三种不同的方法(请参阅下面的删除方法) - 但它们都不起作用。
还有什么问题 - 为什么我的 Siri Shortcut INInteraction 没有被以下代码删除?
let activity = NSUserActivity(activityType: "MyIdentifierStringCodeABCDEF")
let activityPersistentIdentifier = NSUserActivityPersistentIdentifier("MyIdentifierStringCodeABCDEF")
NSUserActivity.deleteSavedUserActivities(withPersistentIdentifiers: [activityPersistentIdentifier]) {
print("one deleted")
}
INInteraction.deleteAll { (error) in
print("all deleted")
}
INInteraction.delete(with: [activityPersistentIdentifier]) { (error) in
print(error)
}