Add pod ZowieSDK
to your Podfile
pod ZowieSDK
To support dependencies that Zowie uses, add the following code at the end of your Podfile
post_install do |installer|
installer.pods_project.targets.each do |target|
if ["Apollo", "Apollo/WebSocket", "Kingfisher", "lottie-ios"].include? target.name
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
end
To be able to use Zowie SDK first of all you have to provide the configuration:
let configuration = ZowieConfiguration(
instanceId: "INSTANCEID",
authType: .anonymous
)
Zowie.shared.set(configuration: configuration)
**Remember, you won't be able to use ANY of SDK functionalities without a proper configuration setup, so be sure you provide it.**
You can clear anonymous session with Zowie.shared.clearAnonymousSession(forInstanceId: "INSTANCEID)
. If your integration requires token authentication you can replace .anonymous
with .token
.
You can access Chat UI from ZowieChatViewController
. Use it just like a regular view controller, so it's up to you how you want to put it in your stack. For example, you can show it from a different view controller:
let chatViewController = ZowieChatViewController()
navigationController?.pushViewController(chatViewController, animated: true)
If you want to handle the chat initialization error, use:
Zowie.shared.onChatInitializationError = { error in
// Do someting
}
You can set needed user metadata. All those fields are optional.
let metadata = ZowieMetadata(
firstName: "first",
lastName: "last",
name: "name",
locale: "locale",
timeZone: "timeZone",
phoneNumber: "123456789",
email: "[email protected]",
extraParams: ["custom": "value"]
)
Zowie.shared.set(metadata: metadata)
To receive FCM notifications you have to provide deviceToken
Zowie.shared.set(fcmToken: "token") { result in
// Completion handler is optional
}
This will allow us to send push notifications to the user's device. Remember that you have set up all required notification-related permissions.
If you want to disable notifications, use:
Zowie.shared.disableNotifications() { result in
// Completion handler is optional
}
You can feed backend with the contextId
Zowie.shared.set(contextId: "contextId") { result in
// Completion handler is optional
}
let config = ZowieLayoutConfiguration(showConsultantAvatar: false, consultantNameMode: .firstName)
Zowie.shared.set(layoutConfiguration: config)
The only supported language in this SDK is english
. If you need more localization please provide it as below:
let strings = ZowieStrings(
messagePlaceholder: "string",
sendFailureErrorMessage: "string",
tryAgain: "string",
delivered: "string",
read: "string",
attachment: "string",
disconnectMessage: "string",
reconnectMessage: "string",
historyErrorMessage: "string"
)
Zowie.shared.set(strings: strings)
Feel free to set up color branding however you like with help of Zowie.shared.set(colors: colors)