https://github.com/1amageek/socialbase
Socialbase is a framework for building SNS in Cloud Firestore.
https://github.com/1amageek/socialbase
cloudfirestore firebase sns social-network
Last synced: 2 months ago
JSON representation
Socialbase is a framework for building SNS in Cloud Firestore.
- Host: GitHub
- URL: https://github.com/1amageek/socialbase
- Owner: 1amageek
- License: mit
- Created: 2018-02-24T14:01:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-27T00:53:35.000Z (over 7 years ago)
- Last Synced: 2025-03-14T16:04:32.646Z (over 1 year ago)
- Topics: cloudfirestore, firebase, sns, social-network
- Language: Swift
- Size: 24.9 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Socialbase
[](http://cocoapods.org/?q=Socialbase)
[](http://cocoapods.org/?q=Socialbase)
[](https://cocoapods.org/pods/Socialbase)
Socialbase is a framework for building SNS in Cloud Firestore.
## Requirements ❗️
- iOS 10 or later
- Swift 4.0 or later
- [Firebase firestore](https://firebase.google.com/docs/firestore/quickstart)
- [Cocoapods](https://github.com/CocoaPods/CocoaPods/milestone/32) 1.4 ❗️ ` gem install cocoapods`
## Installation ⚙
#### [CocoaPods](https://github.com/cocoapods/cocoapods)
- Insert `pod 'Socialbase' ` to your Podfile.
- Run `pod install`.
## Usage
Make your User defined by [Pring](https://github.com/1amageek/Pring) compliant with Socialbase.
```swift
@objcMembers
final class User: Object, Socialbase {
dynamic var name: String = "USER_NAME"
dynamic var type: String = UserType.none.rawValue
// Organizable
let organizations: ReferenceCollection = []
let peoples: ReferenceCollection = []
// Followable
let followers: ReferenceCollection = []
let followees: ReferenceCollection = []
}
```
```swift
extension User {
typealias Invitation = Test.Invitation
}
class Test {
@objcMembers
class Invitation: Object, InvitationProtocol {
typealias Element = User
dynamic var status: String = Status.none.rawValue
dynamic var message: String?
dynamic var toID: String = ""
dynamic var fromID: String = ""
}
}
```
```swift
extension User {
typealias FollowRequest = Test.FollowRequest
}
extension Test {
@objcMembers
class FollowRequest: Object, FollowRequestProtocol {
typealias Element = User
dynamic var status: String = Status.none.rawValue
dynamic var message: String?
dynamic var toID: String = ""
dynamic var fromID: String = ""
}
}
```
Invite users to your organization.
```swift
let user0: User = User(id: "user0", value: [:]) // Organization user
let user1: User = User(id: "user1", value: [:])
let invitation: Test.Invitation = Test.Invitation(fromID: user0.id, toID: user1.id)
invitation.save()
```
Following users.
```swift
let user0: User = User(id: "user0", value: [:])
let user0: User = User(id: "user1", value: [:])
user1.follow(from: user0)
```