Skip to content

Instantly share code, notes, and snippets.

@apatronl
Created July 29, 2020 22:07
Show Gist options
  • Save apatronl/7099b344a9696822efbc4ed4c76a6436 to your computer and use it in GitHub Desktop.
Save apatronl/7099b344a9696822efbc4ed4c76a6436 to your computer and use it in GitHub Desktop.
import Intents
class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any {
// This is the default implementation. If you want different objects to handle different intents,
// you can override this and return the handler you want for that particular intent.
return self
}
}
extension IntentHandler: SelectEmojiIntentHandling {
func provideEmojiOptionsCollection(
for intent: SelectEmojiIntent,
with completion: @escaping (INObjectCollection<EmojiINO>?, Error?) -> Void
) {
var emojiItems = [EmojiINO]()
EmojiProvider.all().forEach { emojiDetails in
let emojiIntentObject =
EmojiINO(identifier: emojiDetails.id, display: "\(emojiDetails.emoji) \(emojiDetails.name)")
emojiItems.append(emojiIntentObject)
}
completion(INObjectCollection(items: emojiItems), nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment