Extract the selected text in custom iOS keyboard extension

6 hours ago 2
ARTICLE AD BOX

I am trying to retrieve the selected text inside a custom keyboard extension.

Using textDocumentProxy.selectedText only provides the prefix and suffix sentences of the selected text, rather than the complete content.

I also tried programmatically moving the cursor and then accessing the truncated parts of the text. However, even while moving the cursor programmatically during text selection, reading documentContextBeforeInput or documentContextAfterInput still does not return the truncated sentences.

How can I reliably obtain the full selected text in a custom keyboard extension?

Read Entire Article