Как удалить ярлык Siri - PullRequest
       106

Как удалить ярлык Siri

1 голос
/ 10 февраля 2020

Я пытаюсь удалить всю поддержку Siri Shortcuts из моего приложения. У меня есть два типа ярлыков, оба создаются пожертвованием INInteraction.

func createDocIntent(for template: Document) -> CreateDocumentIntent {
    let intent = CreateDocumentIntent()
    intent.templateURI = template.URI.absoluteString
    intent.templateTitle = template.title.trimmingCharacters(in: .whitespacesAndNewlines)
    intent.suggestedInvocationPhrase = String(format: LS("siri-shortcut.create-document-suggested-phrase"), template.title.trimmingCharacters(in: .whitespacesAndNewlines))
    return intent
}

func donateCreateDocShortcut(for template: Document) {
    let intent = self.createDocIntent(for: template)
    INInteraction(intent: intent, response: nil).donate { error in
        if let error = error {
            dprintln("Failed to donate CreateDocument shortcut to Siri with error: \(error.localizedDescription)")
        }
    }
}

Чтобы удалить ярлыки, я попытался удалить подклассы Intent, созданные в моем Info.plist, и я попытался вызвать и INInteraction.deleteAll, и NSUserActivity.deleteAllSavedUserActivities, но ни один из них не удаляет ярлыки (см. ниже). Все сделанные пользователем ярлыки по-прежнему доступны в Shorcuts.app и могут быть вызваны с помощью голосовых команд.

    INInteraction.deleteAll { (error) in
        guard let error = error else { return }
        print(error.localizedDescription)
    }
    NSUserActivity.deleteAllSavedUserActivities {
        // Nothing to do
    }

Есть ли еще что-то, что мне нужно сделать, чтобы удалить существующие ярлыки Siri?

...