LiveLike iOS Plugin
Requirements​
- iOS 13.0 and above
Add LiveLike SDK library to your project​
Cocoapods​
pod 'DivaLiveLikePlugin', :git => 'https://github.com/deltatre-vxp/diva-ios-livelike-plugin.git', :tag => '1.0.1'
You will need to have a relevant Personal Access Token with package read permissions in order to utilise this approach.
Usage​
Initialization​
To use the LiveLikePlugin
, you need to initialize it first by calling the init()
method. Here is an example:
let diva = Diva(configuration: /*…*/)
let liveLike = DivaLiveLike(
configuration: example.configuration.settings.liveLike,
pluginsManager: diva.pluginsManager,
api: diva.api
)
Analytics​
A Combine publisher for all the generated analytics in this format:
public struct DivaLiveLikeAnalytics {
var name: String
var data: [String: Any]
}
is available here:
liveLike?.analytics.sink { analytics in
print(analytics.name)
print(analytics.data)
}
LiveLike Influencer Chat Plugin​
The Influencer Chat plugin provides a MenuPanelPlugin that can be used in Diva. Here is an example of how to integrate it:
liveLike?
.addInfluencerChatPlugin()
.start()
There are also optional configurations available to customise some parameters, or fire additional actions at specified times:
liveLike?
.addInfluencerChatPlugin()
.with(title: "My Title") // A custom title for the panel in Diva
.with(analyticsId: "My Custom Analytics Id") // A custom analytics id
.withChatButtonType(.none) // A custom button type that will appear (or not) in the top right buttons in Diva
.withPanelShowAction { /*callback*/ } // A custom action to be fired when the panel appears
.withPanelHideAction { /*callback*/ } // A custom action to be fired when the panel disppears
.withAttentionFlagAction { attentionFlag in /*callback*/ } // A custom action to be fired when there are new unread chat messages
.start()
Customization​
There is the possibility to customize the chat button that appears when the chat is not open (always on iPad, in landscape on iPhone):
public enum ChatButtonType {
// No button will appear
case none
// The default button will appear.
// A custom action can be added to fire when the button is tapped (in addition to the standard behavior of
// opening the chat)
case `default`(customAction: (() -> Void)?)
// A button with the specified state images (one for chat without messages, one for chat with unread messages)
// will appear. A custom action can be added to fire when the button is tapped (in addition to the standard behavior of
// opening the chat)
case custom(defaultImage: UIImage, notificationImage: UIImage, action: (() -> Void)?)
}
LiveLike Widgest Plugin​
The Widgets plugin provides a FloatingPanelPlugin that can be used in Diva. Here is an example of how to integrate it:
liveLike?
.addWidgetPlugin()
.start()
There are also optional configurations available to customise some parameters, or fire additional actions at specified times:
liveLike?
.addWidgetPlugin()
.with(analyticsId: "My Custom Analytics Id") // A custom analytics id
.withPanelShowAction { /*callback*/ } // A custom action to be fired when the panel appears
.withPanelHideAction { /*callback*/ } // A custom action to be fired when the panel disppears
.start()
Customization​
You can customize the Widgets appearance with your own theme by using one of the many available methods:
// Async throwing function, expects json data from a remote URL
livelike.setWidgetsTheme(url: /*Some URL*/)
// Throwing function, expects local json data
livelike.setWidgetsTheme(jsonData: /*Some Data*/)
// Throwing function, expects a valid JSON String
livelike.setWidgetsTheme(jsonString: /*Some JSON String*/)
// Throwing function, expects a valid [String: AnyObject] dictionary
livelike.setWidgetsTheme(json: /*Some JSON Dictionary*/)