isaced / ISEmojiView

Emoji Keyboard for iOS
MIT License
522 stars 119 forks source link

Am trying to show emojikeyboard with custom categories #65

Open Gouthamansriniv opened 3 years ago

Gouthamansriniv commented 3 years ago

Am trying to show emojikeyboard with custom categories this way below by calling func on tap of a button, but below code always opens usual keyboard with all default emojis with categories, any help will be much appreciated

func showEmojiKeyBoard() {
        emojiKeyboard?.delegate = self

        let keyboardSettings = KeyboardSettings(bottomType: .categories)
        emojiKeyboard = EmojiView(keyboardSettings: keyboardSettings)
        if let settingsURL = Bundle.main.path(forResource: "EmojisInCategories", ofType: "plist") {
                       do {
                           var emojiArray: EmojisInCategory?
                           let data = try Data(contentsOf: URL(fileURLWithPath: settingsURL))
                               let decoder = PropertyListDecoder()
                           emojiArray = try decoder.decode(EmojisInCategory.self, from: data)
            keyboardSettings.customEmojis = [
                EmojiCategory(
                    category: Category.custom("My Title", "customCategory"),
                    emojis: [Emoji(emojis: (emojiArray?.Activity)!), Emoji(emojis: ["šŸ¤£"])]
                )
            ]

        } catch {
                print(error)
            }
        }
        keyboardSettings.countOfRecentsEmojis = 20
        keyboardSettings.updateRecentEmojiImmediately = true
    DispatchQueue.main.asyncAfter(deadline: .now() + 0.03) {

            self.view.addSubview((self.emojiKeyboard!));
            self.emojiKeyboard?.addConstaintsToBottomofSuperview(leftOffset: 0, rightOffset: 0, bottomOffset: 0)

        }
}