CometChatExtension
@objc
public protocol CometChatExtension
This is the base protocol to all the custom CometChatExtensions. This protocol defines certain hooks which can be used to perform specific task. This task will be performed on or before or after certain execution of the events
-
This is to identify the each extension ID uniquely. Format of the Extension ID will similar to bundle identifier. e.g. com.cometchat.
Declaration
Swift
@objc func getExtensionID() -> String
Return Value
returns the extensionID
-
onInit hook will be called when the extensions are added inside the sdk.
Declaration
Swift
@objc optional func onInit(appID: String, user: User?)
Parameters
user
currently logged-in (inside sdk) User object
appID
AppID of the which is registered on CometChat Dashboard.
-
onLogin hook will be called after the user is LoggedIn inside the sdk.
Declaration
Swift
@objc optional func onLogin(user: User)
Parameters
user
currently logged-in (inside sdk) User object
-
beforeMessageSent hook will be called just before sending a message to sever.
Declaration
Swift
@objc optional func beforeMessageSent(_ message: BaseMessage) -> BaseMessage
Parameters
message
pass a message object of type BaseMessage which you want to send.
Return Value
It returns a message object of type BaseMessage
-
afterMessageSent hook will be called just after sent the message to server.
Declaration
Swift
@objc optional func afterMessageSent(_ message: BaseMessage) -> BaseMessage
Parameters
message
pass a message object of type BaseMessage which you want to send.
Return Value
It returns a message object of type BaseMessage
-
onMessageReceived hook will be called just after sent the message to server.
Declaration
Swift
@objc optional func onMessageReceived(_ message: BaseMessage) -> BaseMessage
Parameters
message
pass a message object of type BaseMessage which you want to send.
Return Value
It returns a message object of type BaseMessage
-
onMessageListFetched hook will be called just after sent the message to server.
Declaration
Swift
@objc optional func onMessageListFetched(_ messages: [BaseMessage]) -> [BaseMessage]
Parameters
message
pass a message object of type BaseMessage which you want to send.
Return Value
It returns a message object of type BaseMessage
-
onLogout hook will be called after user hits the logout.
- Use: For cleanup and some housekeeping task after logout.
Declaration
Swift
@objc optional func onLogout()