init(_ appId: String)#Methods
#init
Creates a new Engage instance (required to display elements) using your app ID.
The engage object should be retained, so you'll have to instanciate it at class level or store it in a controller that stays alive for the time you're using it.
#createElement
func createElement(_ slug: String, _ target: UIView, options: [String: String] = [:])Presents the desired Engage element in the targeted UIView.
⚠️ This doesn't take display conditions into account. It will print the element no matter what.
#options parameter
The
createElement method can be called with an optional options parameter.#layout
- Type: String
- Accepted values: 'wrap', 'flex'
- Default: 'wrap'
This option allows you to set the kind of layout you want your element to be rendered with.
- Using
wraplayout will shrink the element to its preferred height. - Using
flexlayout will make your element fill the height of the target view it's been put in. Be carefull to leave enough space for your element to show entirely when using this option. Content might be cropped or distorded if the container view is too small in height.
#autoCreate
func autoCreate(filters: [String] = [])Presents multiple elements depending on target condition.
EngageIOS SDK provides a UIView extension for you to add a target value to your views, just do the following:
⚠️ If multiple views have the same target value, the element will only be printed in the first view matching the value.
#commitPageViews
func commitPageViews()Increments the page view counter within your app for elements with a page view count limit.
#config
func config(_ config: [String: Any], _ readOnly: Bool = false)Allows to set some configuration options. See the
configuration options documentation.
#texts
func texts(_ texts: [String: String], locale: String = "en", _ readOnly: Bool = false)Allows to set custom texts all over your elements for the desired locale. See the
texts documentation.
ℹ️ You can set several times the same text value with different locales.
#variables
func variables(_ variables: [String: Any]) -> VoidAllows to set custom variables to be replaced inside some text keys. See the
variables documentation.
#on
func on(_ event: EngageEvent, once: Bool = false)Allows to listen to a specific event in Engage lifecycle (ex: onReady). See
the events documentation.
#off
func off(_ event: EngageEvent)Allows to remove a listener previously set with the
.on method.#setDebug
static func setDebug(_ enabled: Bool)Enables/Disables debugging for all Engage instances.