This repository contains the Speakol iOS SDK source.
Speakol provides endless scrolling of highly- personalized article recommendations, video-view inventory, featured content inventory and related inventory to each visitor on your website. Speakol’s technology seeks to understand visitors and place inventory of interest to them.
This guide is intended for publishers who want to use Speakol to monetize an iOS app that's built natively.
- Insert speakol inventory in UITableView
- Insert speakol inventory in UICollectionView
- Support Image/Video inventory
- iOS 11.0+
See the Podfile Syntax Reference for instructions and options about overriding pod source locations.
Install Cocoapods if need be.
$ gem install cocoapods
Add Speakol-SDK
in your Podfile
.
use_frameworks!
pod 'Speakol-SDK' # not published yet
Then, run the following command.
$ pod install
View |
---|
1. UITableView |
2. UICollectionView |
Here is an example of enclosing Speakol Inventory in UITableView
Firstly, import Speakol SDK
.
import Speakol
Then, add Speakol SDK
initializers to the AppDelegate
enclosed in the didFinishLaunchingWithOptions
method:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
SpeakolManager.shared.speakolToken = "token_from_speakol_portal"
SpeakolManager.shared.widgetId = "widget_id"
SpeakolManager.shared.initializeSpeakolWithToken()
return true
}
- Don’t have the Widget Id? Please refer back to Speakol publisher portal
- In the storyboard, change the class of the designated
UITableView
toSpeakolTableView
.
Note: Set Module to Speakol
.
- First you need to implement
SpeakolTableViewDelegate
, andSpeakolTableViewDataSource
like this:
class ViewController: UIViewController, SpeakolTableViewDelegate, SpeakolTableViewDataSource
- Then you need to set
speakolDelegate
, andspeakolDataSource
speakolTableView.speakolDelegate = self
speakolTableView.speakolDataSource = self
- Use those two Speakol methods instead of the original ones.
func speakolTableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return number_of_your_items_want_to_be_displayed // not the speakol items will be inserted in another section this section is used for the publisher items only
}
func speakolTableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// here you will return the any tableview cell you want to dispaly
let cell = speakolTableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as UITableViewCell
return cell
}
Also if you want to add speakol inventory to the top of your SpeakolTableView
set SpeakolTableView.isTop = true
- By storyboard, changing class of any
UICollectionView
toSpeakolCollectionView
.
Note: Set Module to Speakol
.
- First you need to implement
SpeakolCollectionViewDelegate
,SpeakolCollectionViewDataSource
, andSpeakolCollectionViewDelegateFlowLayout
like this:
class ViewController: UIViewController, SpeakolCollectionViewDelegate, SpeakolCollectionViewDataSource, SpeakolCollectionViewDelegateFlowLayout
- Then you need to set
speakolDelegate
,speakolDataSource
, andspeakolDelegateFlowLayout
collectionView.speakolDelegate = self
collectionView.speakolDataSource = self
collectionView.speakolDelegateFlowLayout = self
- Then implement this method like native collectionView
func speakolCollectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return number_of_your_items_want_to_be_displayed // not the speakol items will be inserted in another section this section is used for the publisher items only
}
func speakolCollectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "VideoCollectionViewCell", for: indexPath) as! UICollectionViewCell
return cell
}
func speakolCollectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let collectionCellSize = collectionView.frame.size.width
return CGSize(width: collectionCellSize/2, height: 100)
}
By then you can enjoy Speakol customized content. Please, refer back to Speakol publisher portal for more customization.