QiscusCore

public class QiscusCore : NSObject

Undocumented

  • Undocumented

    Declaration

    Swift

    public static let shared: QiscusCore
  • Undocumented

    Declaration

    Swift

    public static var dataStore: QiscusStorage
  • Undocumented

    Declaration

    Swift

    public static var database: QiscusDatabaseManager
  • Undocumented

    Declaration

    Swift

    public static var delegate: QiscusCoreDelegate? { get set }
  • Undocumented

    Declaration

    Swift

    public static var enableDebugPrint: Bool
  • set your app Qiscus APP ID, always set app ID everytime your app lounch. \nAfter login successculy, no need to setup again

    Declaration

    Swift

    public class func setup(WithAppID id: String)

    Parameters

    WithAppID

    Qiscus SDK App ID

  • Connect to qiscus server

    Declaration

    Swift

    public class func connect(delegate: QiscusConnectionDelegate? = nil) -> Bool

    Parameters

    delegate

    qiscuscore delegate to listen the event

    Return Value

    true if success connect, please make sure you already login before connect.

  • Setup custom server, when you use Qiscus on premise

    Declaration

    Swift

    public class func set(customServer: URL, realtimeServer: String?, realtimePort port: Int?)

    Parameters

    customServer

    your custom server host

    realtimeServer

    your qiscus realtime host, without port

    realtimePort

    your qiscus realtime port

  • Get Nonce from SDK server. use when login with JWT

    Declaration

    Swift

    public class func getNonce(completion: @escaping (QNonce?, String?) -> Void)

    Parameters

    completion

    @escaping with Optional(QNonce) and String Optional(error)

  • SDK Connect with userId and passkey. The handler to be called once the request has finished.

    • userKey : user password

    Declaration

    Swift

    public class func login(userID: String, userKey: String, completion: @escaping (UserModel?, String?) -> Void)

    Parameters

    userID

    must be unique per appid, exm: email, phonenumber, udid.

    completion

    The code to be executed once the request has finished, also give a user object and error.

  • connect with identityToken, after use nonce and JWT

    Declaration

    Swift

    public class func login(withIdentityToken token: String, completion: @escaping (UserModel?, QError?) -> Void)

    Parameters

    token

    identity token from your server, when you implement Nonce or JWT

    completion

    The code to be executed once the request has finished, also give a user object and error.

  • Disconnect or logout

    Declaration

    Swift

    public static func logout(completion: @escaping (QError?) -> Void)

    Parameters

    completionHandler

    The code to be executed once the request has finished, also give a user object and error.

  • check already logined

    Declaration

    Swift

    public static var isLogined: Bool { get }

    Return Value

    return true if already login

  • Register device token Apns or Pushkit

    Declaration

    Swift

    public func register(deviceToken : String, completion: @escaping (Bool, QError?) -> Void)

    Parameters

    deviceToken

    device token

    completion

    The code to be executed once the request has finished

  • Remove device token

    Declaration

    Swift

    public func remove(deviceToken : String, completion: @escaping (Bool, QError?) -> Void)

    Parameters

    deviceToken

    device token

    completion

    The code to be executed once the request has finished

  • Sync comment

    Declaration

    Swift

    public func sync(lastCommentReceivedId id: String = "", order: String = "", limit: Int = 20, completion: @escaping ([CommentModel]?, QError?) -> Void)

    Parameters

    lastCommentReceivedId

    last comment id, to get id you can call QiscusCore.dataStore.getComments().

    order

    asc or desc only, lowercase. If other than that, it will assumed to desc

    limit

    limit number of comment by default 20

    completion

    return object array of comment and return error if exist

  • get qiscus user from local storage

    Declaration

    Swift

    public static func getProfile() -> UserModel?

    Return Value

    return nil when client not logined, and return object user when already logined

  • Get Profile from server

    Declaration

    Swift

    public func getProfile(completion: @escaping (UserModel?, QError?) -> Void)

    Parameters

    completion

    The code to be executed once the request has finished

  • Start or stop typing in room,

    Declaration

    Swift

    public func isTyping(_ value: Bool, roomID: String, keepTyping: UInt16? = nil)

    Parameters

    value

    set true if user start typing, and false when finish

    roomID

    room id where you typing

    keepTyping

    automatic false after n second

  • Set Online or offline

    Declaration

    Swift

    public func isOnline(_ value: Bool)

    Parameters

    value

    true if user online and false if offline

  • Update user profile

    Declaration

    Swift

    public func updateProfile(displayName: String = "", avatarUrl url: URL? = nil, completion: @escaping (UserModel?, QError?) -> Void)

    Parameters

    displayName

    nick name

    url

    user avatar url

    completion

    The code to be executed once the request has finished

  • Get total unreac count by user

    Declaration

    Swift

    public func unreadCount(completion: @escaping (Int, QError?) -> Void)

    Parameters

    completion

    number of unread cout for all room

  • Block Qiscus User

    Declaration

    Swift

    public func blockUser(email: String, completion: @escaping (MemberModel?, QError?) -> Void)

    Parameters

    email

    qiscus email user

    completion

    Response object user and error if exist

  • Unblock Qiscus User

    Declaration

    Swift

    public func unblockUser(email: String, completion: @escaping (MemberModel?, QError?) -> Void)

    Parameters

    email

    qiscus email user

    completion

    Response object user and error if exist

  • Get blocked user

    Declaration

    Swift

    public func listBlocked(page: Int?, limit:Int?, completion: @escaping ([MemberModel]?, QError?) -> Void)

    Parameters

    page

    page for pagination

    limit

    limit per page

    completion

    Response array of object user and error if exist

  • Upload to qiscus server

    Declaration

    Swift

    public func upload(data : Data, filename: String, onSuccess: @escaping (FileModel) -> Void, onError: @escaping (QError) -> Void, progress: @escaping (Double) -> Void )

    Parameters

    data

    data file to upload

    filename

    file Name

    onSuccess

    return object file model when success

    onError

    return QError

    progress

    progress upload

  • Download

    Declaration

    Swift

    public func download(url: URL, onSuccess: @escaping (URL) -> Void, onProgress: @escaping (Float) -> Void)

    Parameters

    url

    url you want to download

    onSuccess

    resturn local url after success download

    onProgress

    progress download

  • Undocumented

    Declaration

    Swift

    public func sendMessage(roomID id: String, comment: CommentModel, completion: @escaping (CommentModel?, QError?) -> Void)
  • Load Comment by room

    Declaration

    Swift

    public func loadComments(roomID id: String, limit: Int? = nil, completion: @escaping ([CommentModel]?, QError?) -> Void)

    Parameters

    id

    Room ID

    limit

    by default set 20, min 0 and max 100

    completion

    Response new Qiscus Array of Comment Object and error if exist.

  • Load More Message in room

    Declaration

    Swift

    public func loadMore(roomID id: String, lastCommentID commentID: Int, limit: Int? = nil, completion: @escaping ([CommentModel]?, QError?) -> Void)

    Parameters

    roomID

    Room ID

    lastCommentID

    last comment id want to load

    limit

    by default set 20, min 0 and max 100

    completion

    Response new Qiscus Array of Comment Object and error if exist.

  • Delete message by id

    Declaration

    Swift

    public func deleteMessage(uniqueIDs id: [String], type: DeleteType, completion: @escaping ([CommentModel]?, QError?) -> Void)

    Parameters

    uniqueID

    comment unique id

    type

    forMe or ForEveryone

    completion

    Response Comments your deleted

  • Delete all message in room

    Declaration

    Swift

    public func deleteAllMessage(roomID: [String], completion: @escaping (QError?) -> Void)

    Parameters

    roomID

    array of room id

    completion

    Response error if exist

  • Search message

    Declaration

    Swift

    public func searchMessage(keyword: String, roomID: String?, lastCommentId: Int?, completion: @escaping ([CommentModel]?, QError?) -> Void)

    Parameters

    keyword

    required, keyword to search

    roomID

    optional, search on specific room by room id

    lastCommentId

    optional, will get comments aafter this id

  • Mark Comment as read, include comment before

    Declaration

    Swift

    public func updateCommentRead(roomId: String, lastCommentReadId commentID: String)

    Parameters

    roomId

    room id, where comment cooming

    lastCommentReadId

    comment id

  • Mark Comment as received or deliverd, include comment before

    Declaration

    Swift

    public func updateCommentReceive(roomId: String, lastCommentReceivedId commentID: String)

    Parameters

    roomId

    room id, where comment cooming

    lastCommentReceivedId

    comment id

  • Get comment status is read or received

    Declaration

    Swift

    public func readReceiptStatus(commentId id: String, completion: @escaping (CommentModel?, QError?) -> Void)

    Parameters

    id

    comment id

    completion

    return object comment if exist

  • Get or create room with participant

    Declaration

    Swift

    public func getRoom(withUser user: String, completion: @escaping (RoomModel?, QError?) -> Void)

    Parameters

    withUsers

    Qiscus user emaial.

    completion

    Qiscus Room Object and error if exist.

  • Get room by channel name

    Declaration

    Swift

    public func getRoom(withChannel channel: String, completion: @escaping (RoomModel?, QError?) -> Void)

    Parameters

    channel

    channel name or channel id

    completion

    Response Qiscus Room Object and error if exist.

  • Get room with room id

    Declaration

    Swift

    public func getRoom(withID id: String, completion: @escaping (RoomModel?, QError?) -> Void)

    Parameters

    withID

    existing roomID from server or local db.

    completion

    Response Qiscus Room Object and error if exist.

  • Get Room info

    Declaration

    Swift

    public func getRooms(withId ids: [String], completion: @escaping ([RoomModel]?, QError?) -> Void)

    Parameters

    withId

    array of room id

    completion

    Response new Qiscus Room Object and error if exist.

  • Get Room info

    Declaration

    Swift

    public func getRooms(withUniqueId ids: [String], completion: @escaping ([RoomModel]?, QError?) -> Void)

    Parameters

    ids

    Unique room id

    completion

    Response new Qiscus Room Object and error if exist.

  • getAllRoom

    Declaration

    Swift

    public func getAllRoom(limit: Int? = nil, page: Int? = nil,completion: @escaping ([RoomModel]?, Meta?, QError?) -> Void)

    Parameters

    completion

    First Completion will return data from local if exis, then return from server with meta data(totalpage,current). Response new Qiscus Room Object and error if exist.

  • Create new Group room

    Declaration

    Swift

    public func createGroup(withName name: String, participants: [String], avatarUrl url: URL?, completion: @escaping (RoomModel?, QError?) -> Void)

    Parameters

    withName

    Name of group

    participants

    arrau of user id/qiscus email

    completion

    Response Qiscus Room Object and error if exist.

  • update Group or channel

    Declaration

    Swift

    public func updateRoom(withID id: String, name: String?, avatarURL url: URL?, options: String?, completion: @escaping (RoomModel?, QError?) -> Void)

    Parameters

    id

    room id, where room type not single. group and channel is approved

    name

    new room name optional

    avatarURL

    new room Avatar

    options

    String, and JSON string is approved

    completion

    Response new Qiscus Room Object and error if exist.

  • Update Room

    Declaration

    Swift

    public func updateRoom(roomId id: String, name: String?, avatarUrl url: URL?, options: String? = nil, completion: @escaping (RoomModel?, QError?) -> Void)

    Parameters

    name

    room name

    avatarUrl

    room avatar

    options

    options, string or json string

    completion

    Response new Qiscus Room Object and error if exist.

  • Add new participant in room(Group)

    Declaration

    Swift

    public func addParticipant(userEmails emails: [String], roomId: String, completion: @escaping ([MemberModel]?, QError?) -> Void)

    Parameters

    userEmails

    qiscus user email

    roomId

    room id

    completion

    Response new Qiscus Participant Object and error if exist.

  • remove users from room(Group)

    Declaration

    Swift

    public func removeParticipant(userEmails emails: [String], roomId: String, completion: @escaping (Bool, QError?) -> Void)

    Parameters

    emails

    array qiscus email

    roomId

    room id (group)

    completion

    Response true if success and error if exist

  • get participant by room id

    Declaration

    Swift

    public func getParticipant(roomId: String, completion: @escaping ([MemberModel]?, QError?) -> Void)

    Parameters

    roomId

    room id (group)

    completion

    Response new Qiscus Participant Object and error if exist.