Messagekit: Tappable urls within messages

Created on 2 Feb 2018  路  4Comments  路  Source: MessageKit/MessageKit

General Information

How would one implement this feature? I have managed to highlight each individual url in the messages but how would I make each individual link independently tappable?

didTapMessage will not work for this since that applies to the entire message and I might have 8 urls in one message.

question

Most helpful comment

SOLUTION
Put return [.url] in enabledDetectors
(the rest of the data is provided above and just recently this info has also been added to the example app)

All 4 comments

I guess that you already implemented the two delegate methods needed from MessagesDisplayDelegate to highlight and modify how URLs are shown:

func enabledDetectors(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> [DetectorType]

and

func detectorAttributes(for detector: DetectorType, and message: MessageType, at indexPath: IndexPath) -> [NSAttributedStringKey: Any]

So you just need to implement func didSelectURL(_ url: URL) from MessageCellDelegate to obtain the selected URL.

hmm so what exactly do I need to do to make the didSelectURL trigger when tapping a url?

SOLUTION
Put return [.url] in enabledDetectors
(the rest of the data is provided above and just recently this info has also been added to the example app)

How can I know own message of the detected url?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Leon12345679 picture Leon12345679  路  3Comments

ichikmarev picture ichikmarev  路  4Comments

omaralbeik picture omaralbeik  路  4Comments

asn111 picture asn111  路  3Comments

adri4silva picture adri4silva  路  4Comments