behrad-kzm / encryptable-stream-chat-swift

💬 iOS Chat SDK in Swift - Build your own app chat experience for iOS using the official Stream Chat API

Home Page:https://getstream.io/chat/sdk/ios/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement End-to-End Encrypted chat

This function will call when user publish new message:

    ComposerVC.Content.publishEncryptionHandler = { (text) in
        // apply encryption logic to the given text
        return encryptedText
    }

This function will call to decrypt each messages shown in the messageListVC, so you have to provide decryption there:

    messageListVC.publishDecryptionHandler = { (text, authorId) in
        // apply decryption logic with the given text and the authorId
        return decryptedText
    }

this is an example how I used these methodes with VirgilSecurity to implement an e3 chat:

class ChatsContainerVC: ChatChannelVC {
  
  func setup(){
    
      VirgilClient.shared.prepareUsersIfNeeded([userId, otherUserId])
      ComposerVC.Content.publishEncryptionHandler = { (text) in
        return try! VirgilClient.shared.encrypt(text, for: userId)
      }
      
      messageListVC.publishDecryptionHandler = { (text, authorId) in
        return try! VirgilClient.shared.decrypt(text, sender: authorId)
      }
  }
}

then just call setup() when you create an instance of ChatsContainerVC .

Want more info?

visit the original repository and read the README.md file there

About

💬 iOS Chat SDK in Swift - Build your own app chat experience for iOS using the official Stream Chat API

https://getstream.io/chat/sdk/ios/

License:Other


Languages

Language:Swift 98.5%Language:Ruby 0.5%Language:JavaScript 0.3%Language:Shell 0.3%Language:Python 0.3%Language:Makefile 0.0%Language:Objective-C 0.0%