Latest 0.9.1
Homepage https://github.com/1amageek/Muni
License MIT
Platforms ios 10.0, requires ARC
Dependencies Pring, Toolbar, Firebase, Firebase/Firestore, Firebase/Storage
Authors

Chat framework

Feature 🎊

☑️ Serverless – Firebase Cloud Firestore
☑️ Realtime
☑️ Customizable
☑️ Type Safe
☑️ Multi Media

Media

  • Text
  • Image
  • Video
  • Audio
  • Location
  • Sticker
  • ImageMap

Installation ⚙

pod 'Muni' add to your Podfile

pod install

GoogleService-Info.plist add to your Project

Usage

Prepare three documents for cloud firestore.

UserProtocol RoomProtocol TranscriptProtocol create document conforming to each protocol.

@objcMembers
class User: Object, UserProtocol {
    var name: String?
    var thumbnailImage: File?
}
@objcMembers
class Room: Object, RoomProtocol {
    typealias TranscriptType = Transcript
    dynamic var name: String?
    dynamic var thumbnailImage: File?
    dynamic var viewers: [String] = []
    dynamic var members: [String] = []
    dynamic var recentTranscript: [String: Any] = [:]
    dynamic var transcripts: NestedCollection<TranscriptType> = []
    dynamic var config: [String: Any] = [:]
    dynamic var isMessagingEnabled: Bool = true
    dynamic var isHidden: Bool = false
    dynamic var lastViewedTimestamps: [String : Timestamp] = [:]
}
@objcMembers
class Transcript: Object, TranscriptProtocol {
    dynamic var to: Relation<Room> = .init()
    dynamic var from: Relation<User> = .init()
    dynamic var text: String?
    dynamic var image: File?
    dynamic var video: File?
    dynamic var audio: File?
    dynamic var location: GeoPoint?
    dynamic var sticker: String?
    dynamic var imageMap: [File] = []
}

Override two ViewControllers

class MessageViewController: Muni<User, Room, Transcript>.MessagesViewController {

    var sendBarItem: ToolbarItem!

    override var senderID: String? {
        return Auth.auth().currentUser!.uid
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        self.sendBarItem = ToolbarItem(title: "Send", target: self, action: #selector(send))
        self.toolBar.setItems([ToolbarItem(customView: self.textView), self.sendBarItem], animated: false)

        // Start
        self.listen()
    }

    override func transcript(willSend transcript: Transcript) -> Bool {
        guard let text: String = self.textView.text else { return false }
        if text.isEmpty { return false }
        transcript.text = text
        self.textView.text = nil
        return true
    }
}
class BoxViewController: Muni<User, Room, Transcript>.InboxViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Start
        self.listen()
    }

    override func messageViewController(with room: Room) -> Muni<User, Room, Transcript>.MessagesViewController {
        return MessageViewController(roomID: room.id)
    }
}

Build

Muni internally uses Firestore Query.
An error occurs if there is no Index in Firestore. You can create an Index by accessing the URL on the console.

Latest podspec

{
    "name": "Muni",
    "version": "0.9.1",
    "summary": "Firestore message framework",
    "description": "Muni is a chat framework made with Firestore.",
    "homepage": "https://github.com/1amageek/Muni",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "1amageek": "[email protected]"
    },
    "social_media_url": "http://twitter.com/1amageek",
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/1amageek/Muni.git",
        "tag": "0.9.1"
    },
    "source_files": "Muni/**/*.{swift}",
    "resources": "Muni/**/*.{xib}",
    "requires_arc": true,
    "static_framework": true,
    "dependencies": {
        "Pring": [],
        "Toolbar": [],
        "Firebase": [],
        "Firebase/Firestore": [],
        "Firebase/Storage": []
    }
}

Pin It on Pinterest

Share This