QiscusCore
public class QiscusCore : NSObject
Undocumented
-
Undocumented
Declaration
Swift
public static let shared: QiscusCore
-
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, server: QiscusServer? = nil)
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.
-
Sync Time interval, by default is 30s. every 30 sec will be sync when realtime server is disconnect
Declaration
Swift
public class func setSync(interval: TimeInterval)
Parameters
interval
time interval, by default is 30s
-
SDK Login or Register with userId and passkey, if new user register you can set username and avatar The handler to be called once the request has finished.
- userKey : user password
Declaration
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
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, onSuccess: @escaping (Bool) -> Void, onError: @escaping (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, onSuccess: @escaping (Bool) -> Void, onError: @escaping (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, onSuccess: @escaping ([CommentModel]) -> Void, onError: @escaping (QError) -> Void)
Parameters
lastCommentReceivedId
last comment id, to get id you can call QiscusCore.dataStore.getComments().
order
asc
ordesc
only, lowercase. If other than that, it will assumed todesc
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
-
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
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, onSuccess: @escaping (MemberModel) -> Void, onError: @escaping (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, onSuccess: @escaping (MemberModel) -> Void, onError: @escaping (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?, onSuccess: @escaping ([MemberModel]) -> Void, onError: @escaping (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
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, onSuccess: @escaping (CommentModel) -> Void, onError: @escaping (QError) -> Void)
-
Load Comment by room
Declaration
Swift
public func loadComments(roomID id: String, lastCommentId: Int? = nil, timestamp: String? = nil, after: Bool? = nil, limit: Int? = nil, onSuccess: @escaping ([CommentModel]) -> Void, onError: @escaping (QError) -> Void)
Parameters
id
Room ID
timestamp
timestamp
lastCommentId
last recieved comment id before loadmore
after
if true returns comments with id >= last_comment_id. if false and last_comment_id is specified, returns last 20 comments with id < last_comment_id. if false and last_comment_id is not specified, returns last 20 comments
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, timestamp: String? = nil, after: Bool? = nil, limit: Int? = nil, onSuccess: @escaping ([CommentModel]) -> Void, onError: @escaping (QError) -> Void)
Parameters
roomID
Room ID
lastCommentID
last comment id want to load
timestamp
timestamp
after
if true returns comments with id >= last_comment_id. if false and last_comment_id is specified, returns last 20 comments with id < last_comment_id. if false and last_comment_id is not specified, returns last 20 comments
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], onSuccess: @escaping ([CommentModel]) -> Void, onError: @escaping (QError) -> Void)
Parameters
uniqueID
comment unique id
completion
Response Comments your deleted
-
Delete all message in room
Declaration
Swift
public func deleteAllMessage(roomID ids: [String], completion: @escaping (QError?) -> Void)
Parameters
roomID
array of room id
completion
Response error if exist
-
Delete all message in room
Declaration
Swift
public func deleteAllMessage(roomUniqID roomIDs: [String], completion: @escaping (QError?) -> Void)
Parameters
roomUniqID
array of room uniq id
completion
Response error if exist
-
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, onSuccess: @escaping (CommentInfo) -> Void, onError: @escaping (QError) -> Void)
Parameters
id
comment id
completion
return object commentInfo
-
Get or create room with participant
Declaration
Swift
public func getRoom(withUser user: String, avatarUrl: URL? = nil, distincId: String? = nil, options: String? = nil, onSuccess: @escaping (RoomModel, [CommentModel]) -> Void, onError: @escaping (QError) -> Void)
Parameters
withUsers
Qiscus user emaial.
completion
Qiscus Room Object and error if exist.
-
Get or create room by channel name If room with predefined unique id is not exist then it will create a new one with requester as the only one participant. Otherwise, if room with predefined unique id is already exist, it will return that room and add requester as a participant. When first call (room is not exist), if requester did not send avatar_url and/or room name it will use default value. But, after the second call (room is exist) and user (requester) send avatar_url and/or room name, it will be updated to that value. Object changed will be true in first call and when avatar_url or room name is updated.
Declaration
Parameters
channel
channel name or channel id
name
channel name
avatarUrl
url avatar
options
option
onSuccess
return object room
onError
return object QError
-
Get room with room id
Declaration
Swift
public func getRoom(withID id: String, onSuccess: @escaping (RoomModel, [CommentModel]) -> Void, onError: @escaping (QError) -> Void)
Parameters
withID
existing roomID from server or local db.
completion
Response Qiscus Room Object and error if exist.
-
Get Room info
Declaration
Parameters
withId
array of room id
showParticipant
default is false
showRemoved
default is false
completion
Response new Qiscus Room Object and error if exist.
-
Get Room info
Declaration
Parameters
ids
Unique room id
showParticipant
default is false
showRemoved
default is false
completion
Response new Qiscus Room Object and error if exist.
-
getAllRoom
Declaration
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
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
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.
-
Add new participant in room(Group)
Declaration
Swift
public func addParticipant(userEmails emails: [String], roomId: String, onSuccess: @escaping ([MemberModel]) -> Void, onError: @escaping (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, onSuccess: @escaping (Bool) -> Void, onError: @escaping (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(roomUniqeId id: String, offset: Int? = nil, sorting: SortType? = nil, onSuccess: @escaping ([MemberModel]) -> Void, onError: @escaping (QError) -> Void )
Parameters
roomUniqeId
room id (group)
offset
default is nil
sorting
default is asc
completion
Response new Qiscus Participant Object and error if exist.
-
Undocumented
Declaration
Swift
public func leaveRoom(by roomId:String, onSuccess: @escaping (Bool) -> Void, onError: @escaping (QError) -> Void)
-
Undocumented
Declaration
Swift
public func subscribeEvent(roomID: String, onEvent: @escaping (RoomEvent) -> Void)
-
Undocumented
Declaration
Swift
public func unsubscribeEvent(roomID: String)
-
Undocumented
Declaration
Swift
public func publishEvent(roomID: String, payload: [String : Any]) -> Bool