Socialbase 0.5.0

Socialbase 0.5.0

Maintained by 1amageek.



 
Depends on:
Firebase/Core>= 0
Firebase/Firestore>= 0
Firebase/Storage>= 0
Pring>= 0
 

Socialbase

Version Platform Downloads

Socialbase is a framework for building SNS in Cloud Firestore.

Requirements ❗️

Installation ⚙

CocoaPods

  • Insert pod 'Socialbase' to your Podfile.
  • Run pod install.

Usage

Make your User defined by Pring compliant with Socialbase.

@objcMembers
final class User: Object, Socialbase {

    dynamic var name: String = "USER_NAME"
    dynamic var type: String = UserType.none.rawValue

    // Organizable
    let organizations: ReferenceCollection<User> = []
    let peoples: ReferenceCollection<User> = []
    
    // Followable
    let followers: ReferenceCollection<User> = []
    let followees: ReferenceCollection<User> = []
}
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 = ""
    }
}
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.

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.

let user0: User = User(id: "user0", value: [:])
let user0: User = User(id: "user1", value: [:])
user1.follow(from: user0)