Created
July 29, 2020 22:07
-
-
Save apatronl/7099b344a9696822efbc4ed4c76a6436 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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