Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/1amageek/muni
Chat with Cloud Firestore
https://github.com/1amageek/muni
chat cloudfirestore firebase messaging
Last synced: about 2 months ago
JSON representation
Chat with Cloud Firestore
- Host: GitHub
- URL: https://github.com/1amageek/muni
- Owner: 1amageek
- License: mit
- Created: 2018-07-30T10:05:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-03T09:23:16.000Z (almost 6 years ago)
- Last Synced: 2024-11-18T04:44:47.810Z (3 months ago)
- Topics: chat, cloudfirestore, firebase, messaging
- Language: Swift
- Homepage:
- Size: 9.25 MB
- Stars: 23
- Watchers: 4
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Muni
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.``` swift
@objcMembers
class User: Object, UserProtocol {
var name: String?
var thumbnailImage: File?
}
`````` swift
@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 = []
dynamic var config: [String: Any] = [:]
dynamic var isMessagingEnabled: Bool = true
dynamic var isHidden: Bool = false
dynamic var lastViewedTimestamps: [String : Timestamp] = [:]
}
`````` swift
@objcMembers
class Transcript: Object, TranscriptProtocol {
dynamic var to: Relation = .init()
dynamic var from: Relation = .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
```swift
class MessageViewController: Muni.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
}
}
``````swift
class BoxViewController: Muni.InboxViewController {override func viewDidLoad() {
super.viewDidLoad()// Start
self.listen()
}override func messageViewController(with room: Room) -> Muni.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.