Requirements
- iOS 14.0+
- Swift 5.9+
- Xcode 15+
Installation
Swift Package Manager and CocoaPods are two currently supported ways of integrating KontextSwiftSDK into your project.Swift Package Manager (Recommended)
The Swift Package Manager is integrated to Swift and is one of the easiest ways to add a dependency to an iOS app. Once the Swift Package is setup add KontextSwiftSDK into your list of dependencies.File > Add Package Dependencies ...
and paste the URL into search.
CocoaPods
If you prefer CocoaPods instead. Add the following line to yourPodfile
:
Usage
Once you have the dependency added and resolved you should be able to import the SDK.1. Character
Firstly, prepare information about assistant’s Character if it is relevant for this conversation.2. Regulatory
Secondly, prepare information about regulations.3. AdsProviderConfiguration
Thirdly, you need to createAdsProviderConfiguration
. Its information is scoped to one conversation. It uses previously created character
and regulatory
.
4. AdsProvider
Next,AdsProvider
, the object responsible for managing the loading and displaying ads. This is the most important part of the library. It utilizes previously created configuration
.
5. Provide information about messages
Adapt your message object to provide necessary information for the ads recommendation to work. You have two options, either make them conform toMessageRepresentable
to return respective properties or to MessageRepresentableProviding
and return the MessageRepresentable
as a whole new object. There is struct AdsMessage: MessageRepresentable
which you can use for this scenario.
6. Insert InlineAdView into view hierarchy
The last thing remaining is to provide place for the Ads to manifest into. This is done by placingInlineAdView
into View hierarchy just after the associated message. The view will take care of loading the ad.
InlineAdUIView
instead and refer to the ExampleUIKit app.
Now you are set up and ready to go 🎉