0

I'm trying to open url from messages and i'm using 3.0.0-beta-swift5 version of MessageKit. I implemented the delegate methods.

    func detectorAttributes(for detector: DetectorType, and message: MessageType, at indexPath: IndexPath) -> [NSAttributedString.Key: Any] {
     switch detector {
     case .hashtag, .mention, .url: return [.foregroundColor: UIColor.blue]
     default: return MessageLabel.defaultAttributes
     }
   }

 func enabledDetectors(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> [DetectorType] {
     return [.url, .address, .phoneNumber, .date, .transitInformation, .mention, .hashtag]
 }

I implemented the didSelectURL but it doesn't triggered.

func didSelectURL(_ url: URL) {
        let config = SFSafariViewController.Configuration()

        let vc = SFSafariViewController(url: url, configuration: config)
        present(vc, animated: true)
}
  • 1
    Did you set the `MessageLabelDelegate` ? – koen Mar 24 '20 at 12:16
  • Yeah i forget MessageLabelDelegate thank you it worked. – redwheelbarrow Mar 24 '20 at 12:39
  • The `MessageCellDelegate` implements the `MessageLabelDelegate`, so you need to make sure that the `messagesCollectionView.messageCellDelegate` is set to the `ChatViewController` and that the ChatViewController has an extension for MessageCellDelegate where you can put your `didSelectURL` – Pravalika Jun 09 '20 at 21:28

0 Answers0