iOS Keyboard Extension: Memoji like paste

942 Views Asked by At

Apples build in Emoji Keyboard has a section with "Memoji" stickers. If you tap on any of these stickers (it seems to be a PNG image), then it's automatically inserted into the textfield or into the chat of the current App, for example WhatsApp, Facebook Messenger or iMessage.

WhatsApp with Memoji

Is it possible to get the same functionality with a custom keyboard? Or is Apple using some private API for the Memoji stickers?

I know how to add an image or image data to the pasteboard like UIPasteboard.general.image or UIPasteboard.general.setData(...). But if I do so, the png image isn't pasted automatically into the textfield. The user has to do additional steps and tap with the finger into the textfield and select "paste".

1

There are 1 best solutions below

2
On

All the mentioned apps use UITextView, upon selection of any sticker the OS adds this image as an NSTextAttachment to the attributedString of the text view