Live Chat
Implementation
- Implement the
VFLoginDelegate. This delegate will be called when the user tries to interact with the container in a way that needs authentication. For example: Liking a comment or trying to create their own comment.
Your app should present your authentication flow and authenticate with Viafoura SDK Authenticate your users
extension ArticleViewController: VFLoginDelegate {
func startLogin() {
// Launch your custom login/signup flow
}
}- Create your
VFArticleMetadataobject.
let articleMetadata = VFArticleMetadata(
url: "https://demo.viafoura.com/posts/so-you-got-new-engagement-tools-now-what",
title: "So you got New Engagement Tools, Now What?",
subtitle: "What better way to grow a community than with on-site engagement tools?",
thumbnailUrl: "https://www.datocms-assets.com/55856/1636662761-impact-engagement.jpg?fit=crop&fm=webp&h=428&w=856")| Value | Type | Description |
|---|---|---|
url | URL String | URL of the content |
title | String | Title of the content |
subtitle | String | Subtitle of the content |
thumbnailUrl | URL String | Content thumbnail URL |
- Create your
VFSettingsobject.
For customization options, refer to Use custom colors and fonts
let colors = VFColors(colorPrimary: .green, colorPrimaryLight: .systemGreen)
let settings = VFSettings(colors: colors)- Create the chat view controller.
let vc = VFLiveChatViewController.new(
containerId: "containerId",
articleMetadata: metadata,
loginDelegate: self,
settings: settings
)- Add the chat view to your view controller. Make sure you have created a container view to add the conversation VC into.
addChild(preCommentsViewController)
youCommentsContainerView.addSubview(preCommentsViewController.view)
preCommentsViewController.view.frame = CGRect(x: 0, y: 0, width: yourCommentsContainerView.frame.width, height: preCommentsViewController.view.frame.height)
preCommentsViewController.willMove(toParent: self)
preCommentsViewController.didMove(toParent: self)Updated about 1 month ago
What’s Next
